You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NOTE: I print "result" just to eliminate very unlikely case where compiler can optimize stuff away.
Now let's conduct a number of experiments
comment out both warmup calls:
result=-1, time=251 -- YES! It can run by 4 times faster!
result=-1, time=935
with warmup calls both commented out, go to testIndexOf16 and replace Uint16List with Uint8List constructor:
result=-1, time=290
result=-1, time=240
And so on. I managed to get all possible combinations of ~200, ~900 milliseconds by randomly commenting/uncommenting stuff.
How one method affects the other is a mystery. One gets deoptimized because the other one gets optimized? Or one gets optimized because the other one gets de-optimized? But sometimes they are both optimized, and at other times both de-optimized? I admit I wasn't able to discover a pattern.
The text was updated successfully, but these errors were encountered:
List.indexOf is faster when running with a monomorphic state (Uint8List) then in polymorphic (Uint8List, Uint16List) Once more than one receiver type is used for calling List.indexOf, more checks is needed. This will be solved once specialization is implemented.
This issue was originally filed by @tatumizer
Please run the following program (I tested on Windows, not sure if Linux has the same effect).
import 'dart:typed_data';
int iterations=10000000;
testIndexOf8() {
var list=new Uint8List(8);
int x=0;
for (int i=0; i<iterations; i++) {
x|=list.indexOf(1);
}
return x;
}
testIndexOf16() {
var list=new Uint16List(8);
int x=0;
for (int i=0; i<iterations; i++) {
x|=list.indexOf(1);
}
return x;
}
main() {
var w;
testIndexOf8(); // warmup
testIndexOf16(); // warmup
w = new Stopwatch()..start();
print("result=${testIndexOf8()}, time=${w.elapsedMilliseconds}");
w.reset();
print("result=${testIndexOf16()}, time=${w.elapsedMilliseconds}");
}
printout:
result=-1, time=850
result=-1, time=884
NOTE: I print "result" just to eliminate very unlikely case where compiler can optimize stuff away.
Now let's conduct a number of experiments
result=-1, time=251 -- YES! It can run by 4 times faster!
result=-1, time=935
result=-1, time=290
result=-1, time=240
And so on. I managed to get all possible combinations of ~200, ~900 milliseconds by randomly commenting/uncommenting stuff.
How one method affects the other is a mystery. One gets deoptimized because the other one gets optimized? Or one gets optimized because the other one gets de-optimized? But sometimes they are both optimized, and at other times both de-optimized? I admit I wasn't able to discover a pattern.
The text was updated successfully, but these errors were encountered: