Skip to content

Commit

Permalink
start to track performance evolution
Browse files Browse the repository at this point in the history
  • Loading branch information
ichiriac committed Jan 2, 2020
1 parent 917acf3 commit 492bcfb
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 12 deletions.
27 changes: 15 additions & 12 deletions test/perf.test.js
@@ -1,5 +1,7 @@
var parser = require("./main");

const parser = require("./main");
const os = require("os");
const cpus = os.cpus();
const cpuId = cpus.length + "@" + cpus[0].speed + 'Mhz';
describe("Performance tests", function() {
var code = `
<?php
Expand All @@ -15,6 +17,7 @@ describe("Performance tests", function() {
}
`;

console.log("Testing perfs on " + cpuId + " / " + cpus[0].model);
it("tokenizer", function() {
var reader = new parser();
var tokSize = reader.tokenGetAll(code).length;
Expand All @@ -34,9 +37,9 @@ describe("Performance tests", function() {
speed = speed / 1000;
if (speed > 1000) {
speed = speed / 1000;
speed = Math.round(speed * 100) / 100 + "M";
speed = Math.round(speed * 100) / 100 + "M Tokens";
} else {
speed = Math.round(speed * 100) / 100 + "K";
speed = Math.round(speed * 100) / 100 + "K Tokens";
}
}
console.log(" + Tokens speed => " + speed + "/sec");
Expand All @@ -48,12 +51,12 @@ describe("Performance tests", function() {
speed = speed / 1024;
if (speed > 1024) {
speed = speed / 1024;
speed = Math.round(speed * 100) / 100 + "M";
speed = Math.round(speed * 100) / 100 + " Mb";
} else {
speed = Math.round(speed * 100) / 100 + "K";
speed = Math.round(speed * 100) / 100 + " Kb";
}
}
console.log(" + Reading speed => " + speed + "/sec");
console.log(" + Reading bandwidth => " + speed + "/sec");
});

it("parser", function() {
Expand Down Expand Up @@ -93,9 +96,9 @@ describe("Performance tests", function() {
speed = speed / 1000;
if (speed > 1000) {
speed = speed / 1000;
speed = Math.round(speed * 100) / 100 + "M";
speed = Math.round(speed * 100) / 100 + "M Nodes";
} else {
speed = Math.round(speed * 100) / 100 + "K";
speed = Math.round(speed * 100) / 100 + "K Nodes";
}
}
console.log(" + Nodes speed => " + speed + "/sec");
Expand All @@ -107,11 +110,11 @@ describe("Performance tests", function() {
speed = speed / 1024;
if (speed > 1024) {
speed = speed / 1024;
speed = Math.round(speed * 100) / 100 + "M";
speed = Math.round(speed * 100) / 100 + " Mb";
} else {
speed = Math.round(speed * 100) / 100 + "K";
speed = Math.round(speed * 100) / 100 + " Kb";
}
}
console.log(" + Overall speed => " + speed + "/sec");
console.log(" + Overall bandwidth => " + speed + "/sec");
});
});
Empty file added test/perf/class.php
Empty file.
21 changes: 21 additions & 0 deletions test/perf/statistics.json
@@ -0,0 +1,21 @@
{
"threshold": {
"tokens": 0.95,
"nodes": 0.9
},
"versions": {
"3.0.0-prerelease.9": {
"12@3674Mhz": {
"model": "AMD Ryzen 5 2600 Six-Core Processor",
"files": {
"class.php": {
"tokensPerSec": 29091000,
"tokenBandwidth": 61984000,
"nodesPerSec": 7731000,
"parseBandwidth": 20513000
}
}
}
}
}
}

0 comments on commit 492bcfb

Please sign in to comment.