Skip to content

Commit 2d1a8b1

Browse files
committed
Add latest optimizations and switch back to standard tests.json format since I have another file
1 parent d2b78f0 commit 2d1a8b1

File tree

4 files changed

+515
-3761
lines changed

4 files changed

+515
-3761
lines changed

bench/test.js

+14-11
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { isDeepStrictEqual } from 'util'
44
import jl from 'json-logic-js'
55
import rust from '@bestow/jsonlogic-rs'
66

7-
const x = new LogicEngine(undefined, { compatible: true })
8-
const y = new AsyncLogicEngine(undefined, { compatible: true })
7+
const x = new LogicEngine()
8+
const y = new AsyncLogicEngine()
99

1010
const compatible = []
1111
const incompatible = []
@@ -21,8 +21,8 @@ JSON.parse(fs.readFileSync('./tests.json').toString()).forEach((test) => {
2121
compatible.push(test)
2222
}
2323
} catch (err) {
24-
// console.log(err)
25-
// console.log(test[0])
24+
// console.log(err)
25+
// console.log(test[0])
2626
incompatible.push(test)
2727
}
2828
}
@@ -32,6 +32,9 @@ console.log(
3232
incompatible.length,
3333
compatible.length / (compatible.length + incompatible.length)
3434
)
35+
36+
x.optimizedMap = new WeakMap()
37+
3538
// eslint-disable-next-line no-unused-vars
3639
const defined = [
3740
[{ '+': [1, 2, 3, 4, 5] }, {}],
@@ -69,13 +72,13 @@ for (let j = 0; j < tests.length; j++) {
6972
}
7073
console.timeEnd('json-logic-js')
7174

72-
console.time('json-logic-rs')
73-
for (let j = 0; j < tests.length; j++) {
74-
for (let i = 0; i < 1e5; i++) {
75-
rust.apply(tests[j][0], tests[j][1])
76-
}
77-
}
78-
console.timeEnd('json-logic-rs')
75+
// console.time('json-logic-rs')
76+
// for (let j = 0; j < tests.length; j++) {
77+
// for (let i = 0; i < 1e5; i++) {
78+
// rust.apply(tests[j][0], tests[j][1])
79+
// }
80+
// }
81+
// console.timeEnd('json-logic-rs')
7982

8083
x.disableInterpretedOptimization = true
8184
console.time('le interpreted')

0 commit comments

Comments
 (0)