forked from sequelize/sequelize-performance
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcheck-performance.js
40 lines (33 loc) · 1.25 KB
/
check-performance.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const TIMES = parseInt(process.env.TIMES || 2)
, LIMIT = parseInt(process.env.LIMIT || 1000)
var runMySqlTest = require("./mysql")
, runNodeOrmTest = require("./node-orm")
, runPersistenceTest = require("./persistencejs")
, runSequelizeTest = require("./sequelize")
var printDurations = function(lib, durations) {
console.log()
for(var testName in durations[0]) {
var sum = 0
, msg = "{{lib}}#{{testName}} ({{times}} runs): {{duration}}ms"
durations.forEach(function(res) { sum += res[testName] })
msg = msg
.replace('{{lib}}', lib)
.replace('{{testName}}', testName)
.replace('{{times}}', durations.length)
.replace('{{duration}}', sum / durations.length)
console.log(msg)
}
}
runMySqlTest(TIMES, LIMIT, function(mySqlDurations) {
runNodeOrmTest(TIMES, LIMIT, function(nodeOrmDurations) {
runSequelizeTest(TIMES, LIMIT, function(sequelizeDurations) {
runPersistenceTest(TIMES, LIMIT, function(persistenceDurations) {
printDurations('node-mysql', mySqlDurations)
printDurations('node-orm', nodeOrmDurations)
printDurations('persistencejs', persistenceDurations)
printDurations('sequelize', sequelizeDurations)
process.exit()
})
})
})
})