ff99a0ce59
This is the result of: - taking the diff of the branch closure_conversion to master in the kernel repository - updating the file paths - applying the diff to the Dart SDK - fixing conflicts between the changes to pkg/kernel in the Dart SDK and the master branch in the kernel repository R=asgerf@google.com Review-Url: https://codereview.chromium.org/2561723003 .
65 lines
1.5 KiB
Dart
65 lines
1.5 KiB
Dart
import 'package:kernel/type_propagation/canonicalizer.dart';
|
|
|
|
main() {
|
|
Stopwatch watch = new Stopwatch()..start();
|
|
|
|
const int lowBiasKeys = 100;
|
|
const int highBiasKeys = 10000;
|
|
const int noBiasKeys = 1000;
|
|
|
|
Uint31PairMap map;
|
|
|
|
// Warm up.
|
|
map = new Uint31PairMap();
|
|
for (int i = 0; i < noBiasKeys; ++i) {
|
|
for (int j = 0; j < noBiasKeys; ++j) {
|
|
map.lookup(i, j);
|
|
map.put(i + j);
|
|
}
|
|
}
|
|
|
|
// Even distributed tuple components.
|
|
watch.reset();
|
|
map = new Uint31PairMap();
|
|
for (int i = 0; i < noBiasKeys; ++i) {
|
|
for (int j = 0; j < noBiasKeys; ++j) {
|
|
map.lookup(i, j);
|
|
map.put(i + j);
|
|
}
|
|
}
|
|
int noBiasTime = watch.elapsedMicroseconds;
|
|
|
|
// Left-bias: more unique keys in the first component.
|
|
watch.reset();
|
|
map = new Uint31PairMap();
|
|
for (int i = 0; i < highBiasKeys; ++i) {
|
|
for (int j = 0; j < lowBiasKeys; ++j) {
|
|
map.lookup(i, j);
|
|
map.put(i + j);
|
|
}
|
|
}
|
|
int leftBiasTime = watch.elapsedMicroseconds;
|
|
|
|
// Right-bias: more unique keys in the second component.
|
|
watch.reset();
|
|
map = new Uint31PairMap();
|
|
for (int i = 0; i < lowBiasKeys; ++i) {
|
|
for (int j = 0; j < highBiasKeys; ++j) {
|
|
map.lookup(i, j);
|
|
map.put(i + j);
|
|
}
|
|
}
|
|
int rightBiasTime = watch.elapsedMicroseconds;
|
|
|
|
print('''
|
|
bias.none: ${formatTime(noBiasTime)}
|
|
bias.left: ${formatTime(leftBiasTime)}
|
|
bias.right: ${formatTime(rightBiasTime)}
|
|
''');
|
|
}
|
|
|
|
String formatTime(int microseconds) {
|
|
double seconds = microseconds / 1000000.0;
|
|
return '$seconds s';
|
|
}
|