Skip to content

Commit c8da51a

Browse files
committed
Force a perf regression
1 parent 87cfcf8 commit c8da51a

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

main.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,27 @@ class DummyRewriter {
2323

2424
let NativeRewriter
2525

26+
function isPrime(num) {
27+
for (let i = 2; i < num; i++) {
28+
if (num % i === 0) {
29+
return false;
30+
}
31+
}
32+
return true;
33+
}
34+
const total = []
2635
class NonCacheRewriter {
2736
constructor (config) {
37+
// force a performance regression
38+
for (let i = 0; i < 10000; i++) {
39+
if (isPrime(i)) {
40+
total.push(i)
41+
}
42+
}
43+
if (total.length < 0) {
44+
console.log('total init', total.length)
45+
}
46+
2847
if (NativeRewriter) {
2948
this.nativeRewriter = new NativeRewriter(config)
3049
this.setLogger(config)
@@ -38,6 +57,15 @@ class NonCacheRewriter {
3857
}
3958

4059
rewrite (code, file, passes) {
60+
// force a performance regression
61+
for (let i = 0; i < 10000; i++) {
62+
if (isPrime(i)) {
63+
total.push(i)
64+
}
65+
}
66+
if (total.length < 0) {
67+
console.log('never executed', total.length)
68+
}
4169
let moduleName
4270
let moduleVersion
4371
if (passes.includes('orchestrion')) {

0 commit comments

Comments
 (0)