Skip to content

Commit 7f6ecbc

Browse files
authored
Create an user adjustable table for Perf metrics (#1000)
- create packages for BenchmarkMathCalculation.js. It can be shared by both client and server code - remove TestResultSummaryService/perf/BenchmarkMathCalculation.js - create user adjustable MetricTable resolves: automation/issues/235 Signed-off-by: Lan Xia <[email protected]>
1 parent 1c599eb commit 7f6ecbc

20 files changed

+519
-113
lines changed

TestResultSummaryService/package-lock.json

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

TestResultSummaryService/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"mathjs": "^7.6.0",
3939
"mongodb": "^3.6.10",
4040
"request": "^2.88.2",
41+
"utils": "file:../packages/utils",
4142
"winston": "^2.4.5"
4243
},
4344
"devDependencies": {

TestResultSummaryService/perf/BenchmarkMathCalculation.js

-84
This file was deleted.

TestResultSummaryService/perf/DataManagerAggregate.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const BenchmarkMath = require('./BenchmarkMathCalculation');
1+
const BenchmarkMath = require('utils/BenchmarkMathCalculation');
22
const math = require('mathjs');
33
const ObjectID = require('mongodb').ObjectID;
44

TestResultSummaryService/routes/getAzDoRun.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const DefaultParser = require('../parsers/Default');
44
const DataManagerAggregate = require('../perf/DataManagerAggregate');
55
const ArgParser = require('../ArgParser');
66
const math = require('mathjs');
7-
const BenchmarkMath = require('../perf/BenchmarkMathCalculation');
7+
const BenchmarkMath = require('utils/BenchmarkMathCalculation');
88

99
module.exports = async (req, res) => {
1010
const { user, password, server } =
@@ -54,14 +54,16 @@ module.exports = async (req, res) => {
5454
}
5555
const results = JSON.parse(body.body);
5656
// extract worker name from timeline
57-
const agentName = results.records.find(
58-
(job) =>
59-
job.name.startsWith(`Run ${buildInfo.templateParameters.suite}`)
57+
const agentName = results.records.find((job) =>
58+
job.name.startsWith(
59+
`Run ${buildInfo.templateParameters.suite}`
60+
)
6061
).workerName;
6162
// find the log with the name of the benchmark
62-
const logURL = results.records.find(
63-
(job) =>
64-
job.name.startsWith(`Run ${buildInfo.templateParameters.suite}`)
63+
const logURL = results.records.find((job) =>
64+
job.name.startsWith(
65+
`Run ${buildInfo.templateParameters.suite}`
66+
)
6567
).log.url;
6668
// fetch the log
6769
request.get(

TestResultSummaryService/routes/getData.js

-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@ module.exports = async (req, res) => {
77
if (query.parentId) query.parentId = new ObjectID(query.parentId);
88
const db = new TestResultsDB();
99
const result = await db.getData({ _id: new ObjectID(query._id) }).toArray();
10-
console.log(result);
1110
res.send(result);
1211
};

node_modules/.package-lock.json

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

+11-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# dependencies
2+
node_modules
+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
const math = require("mathjs");
2+
3+
class BenchmarkMathCalculation {
4+
// Taken from Perffarm/perfsite/benchmarks.php
5+
/*
6+
* This function calculates the confidence interval of a set
7+
* of results. We are limited to testing for 5%
8+
* convergence.
9+
*/
10+
static confidence_interval(scores) {
11+
let scores_sum = 0;
12+
scores.forEach((x) => {
13+
if (x !== null) {
14+
scores_sum += x;
15+
}
16+
});
17+
18+
// First get the std deviation and other
19+
// useful values as floats.
20+
if (scores_sum !== 0) {
21+
let stddev = math.std(scores);
22+
let count = scores.length;
23+
let mean = scores_sum / count;
24+
25+
// Do the convergence calculations.
26+
let ci = stddev * this.t_dist05(count - 1);
27+
ci /= mean;
28+
ci /= Math.sqrt(count);
29+
30+
return ci;
31+
} else {
32+
return 0;
33+
}
34+
}
35+
36+
// Taken from Perffarm/perfsite/benchmarks.php
37+
/*
38+
* This is a lookup function for the t-distribution.
39+
* It is based on the statistical tests code Dave
40+
* Siegwart wrote for RAJ.
41+
* It only does probability of 0.05.
42+
*/
43+
static t_dist05(N) {
44+
// Constants for t-dist calculations.
45+
let Student_t_05 = [
46+
-1.0, 12.706, 4.303, 3.182, 2.776, 2.571, 2.447, 2.365, 2.306, 2.262,
47+
2.228,
48+
49+
2.201, 2.179, 2.16, 2.145, 2.131, 2.12, 2.11, 2.101, 2.093, 2.086,
50+
51+
2.08, 2.074, 2.069, 2.064, 2.06, 2.056, 2.052, 2.048, 2.045, 2.042,
52+
];
53+
let Student_t_05_40 = 2.021;
54+
let Student_t_05_60 = 2.0;
55+
let Student_t_05_120 = 1.98;
56+
let Student_t_05_2000 = 1.96;
57+
58+
let P = 0.0;
59+
60+
if (N <= 30) {
61+
P = Student_t_05[N];
62+
} else if (N <= 40) {
63+
P = this.interp(Student_t_05[30], Student_t_05_40, 30, 40, N);
64+
} else if (N <= 60) {
65+
P = this.interp(Student_t_05_40, Student_t_05_60, 40, 60, N);
66+
} else if (N <= 120) {
67+
P = this.interp(Student_t_05_60, Student_t_05_120, 60, 120, N);
68+
} else if (N <= 2000) {
69+
P = this.interp(Student_t_05_120, Student_t_05_2000, 120, 2000, N);
70+
} else {
71+
P = Student_t_05_2000;
72+
}
73+
return P;
74+
}
75+
76+
// Taken from Perffarm/perfsite/benchmarks.php
77+
// Support function for t_dist05
78+
static interp(a, b, aN, bN, N) {
79+
let mu = (N - aN) / (bN - aN);
80+
let v = mu * (b - a) + a;
81+
return v;
82+
}
83+
}
84+
module.exports = BenchmarkMathCalculation;

0 commit comments

Comments
 (0)