Zip even worse than plain for?

link
size bigger , and even less performance ??
source : I got it from this topic

I used godbolt to test .
There are 2 case :
first one using : plain for.
the second one is using : zip
although: the size of zip is clearly bigger.
but in performance: it’s not actually clear
Does the method using time std is not a good choice.
Can anyone have another suggestions.
besides:
If the tests confirm this, can I conclude that we should prefer using a plain for loop over zip combined with map, for_each, and similar methods if possible ?

Well they do different things. Try using different-length vectors.

2 Likes

if the vec1.len() != vec2.len()
we can simple do

let len = if self.vec.len()>rhs.vec.len() {rhs.vec.len()}else{self.vec.len()};

It got a same result

Or just let len = self.vec.len().min(rhs.vec.len()); yeah.

Here's a simplified comparison: looks pretty close to identical barring some different registers

1 Like

yeah. I forgot about it

The link doesn't work for me, godbolt shows a decode error. Maybe try generating a short link?

Dang it. Looks like if you use the link helper in this editor it adds a level of URL-encoding, which seems broken. Should be fixed now?

do you the answer? there has been no one answer yet

If you want an answer other than the ones you have received so far, you’ll need to state your question more clearly. Use more words and specify what information you want, or what problem you want to solve.

2 Likes

You might have misunderstood. My link was not showing that min was identical. It was showing that the explicit loop with min and zip were nearly identical.

1 Like

Thank you.
You are right! I will change my post.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.