Closed knupel closed 1 year ago
This isn't a replacement, unfortunately. The performance increase is largely coming from changing the function of the reverse method. It reverses in place rather than returning a new array that's been reversed.
@benfry are interessting if I made the changement with a new array instead ?
Does it actually improve performance in that case? I assume perhaps a little but I'd be surprised if the difference is significant.
Hi it's August holyday time now, and I find a little time to improve the reverse() and reverse_copy() algo to see if when I add a copy array function in it, that's ok... For the major cases that's better of the original, but like you write @benfry the performance decrease, but stay a good think... Now there only two cases where it's slower: for String
and for boolean
If I understand well the performance decrease for the small data... because for long
it's amazing and step by step when we go closer to a very small data (boolean) the performance decrease. I just don't undestand why the performance is bad for the String. Because for me String is a Class...and I think the performance must be equal to Class Machin
or PVector
but NOOOOOOOOO.
Below the result, If the performance is ok for you and you are interesting. I can write a pullrequest for that.
// GOOD CASE
// double
// reverse Rope faster x120
// reverse_copy Rope faster x43
// long
// reverse() Rope faster x120
// reverse_copy() Rope faster x45
// class Float
// reverse Rope faster x8.5
// reverse_copy Rope faster x6.5
// class Integer
// reverse Rope faster x8.5
// reverse_copy Rope faster x4.7
// PVector
// reverse() Rope faster x8
// reverse_copy() Rope faster x7
// class Machin
// reverse Rope faster x8
// reverse_copy Rope faster x4.5
// int
// reverse() Rope faster x4
// reverse_copy() Rope faster x2
// float
// reverse() Rope faster x4
// reverse_copy() Rope faster x2
// char
// reverse Rope faster x2.2
// reverse_copy Rope faster x1.8
// BAD CASE
// boolean
//reverse() Rope faster x1.2
//reverse_copy() Rope slower x0.8 // BAD
// String
//reverse() Rope faster x1.8
//reverse_copy() Rope slower x0.8 // BAD
If it's still faster I'm happy to take on a PR. If possible, please do your best to stick with the Style Guidelines so I don't need to rewrite it. Thanks!
Change the algorithm to compute the half of the array and swap the rest. Plus add reverse for long and double, just in case !!!
Here a test the difference of speed.
to compare easily the performance, may me you need to install the rope Library or copy and paste the new function reverse() https://github.com/knupel/Rope/blob/master/build_rope/Rope.zip