-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
531 additions
and
245 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/usr/bin/env node | ||
import { execSync } from 'child_process'; | ||
import * as path from 'path'; | ||
import * as fs from 'fs'; | ||
import { servers, formattedServerNames } from './analyze/config'; | ||
import { createDirectoryIfNotExists, moveFile, readFileContent } from './analyze/fileUtils'; | ||
import { parseServerMetrics } from './analyze/parser'; | ||
import { writeMetricsDataFiles } from './analyze/dataFileWriter'; | ||
import { generateGnuplotScript, writeGnuplotScript } from './analyze/gnuplotGenerator'; | ||
import { formatResults, writeResults } from './analyze/resultsFormatter'; | ||
|
||
const resultFiles: string[] = process.argv.slice(2); | ||
|
||
// Read content of result files | ||
const resultContents: string[] = resultFiles.map(file => readFileContent(file)); | ||
|
||
const serverMetrics = parseServerMetrics(servers, resultContents); | ||
|
||
writeMetricsDataFiles(serverMetrics, servers); | ||
|
||
let whichBench = 1; | ||
if (resultFiles.length > 0) { | ||
if (resultFiles[0].startsWith("bench2")) { | ||
whichBench = 2; | ||
} else if (resultFiles[0].startsWith("bench3")) { | ||
whichBench = 3; | ||
} | ||
} | ||
|
||
function getMaxValue(data: string): number { | ||
try { | ||
return Math.max(...data.split('\n') | ||
.slice(1) | ||
.map(line => { | ||
const [, valueStr] = line.split(' '); | ||
const value = parseFloat(valueStr); | ||
if (isNaN(value)) { | ||
throw new Error(`Invalid number in data: ${valueStr}`); | ||
} | ||
return value; | ||
})); | ||
} catch (error) { | ||
console.error(`Error getting max value: ${(error as Error).message}`); | ||
return 0; | ||
} | ||
} | ||
|
||
const reqSecMax = getMaxValue(readFileContent('/tmp/reqSec.dat')) * 1.2; | ||
const latencyMax = getMaxValue(readFileContent('/tmp/latency.dat')) * 1.2; | ||
|
||
const gnuplotScript = generateGnuplotScript(whichBench, reqSecMax, latencyMax); | ||
writeGnuplotScript(gnuplotScript); | ||
|
||
try { | ||
execSync(`gnuplot /tmp/gnuplot_script.gp`, { stdio: 'inherit' }); | ||
console.log('Gnuplot executed successfully'); | ||
} catch (error) { | ||
console.error('Error executing gnuplot:', (error as Error).message); | ||
} | ||
|
||
const assetsDir = path.join(__dirname, "assets"); | ||
createDirectoryIfNotExists(assetsDir); | ||
|
||
moveFile(`req_sec_histogram${whichBench}.png`, path.join(assetsDir, `req_sec_histogram${whichBench}.png`)); | ||
moveFile(`latency_histogram${whichBench}.png`, path.join(assetsDir, `latency_histogram${whichBench}.png`)); | ||
|
||
const resultsTable = formatResults(serverMetrics, formattedServerNames, whichBench); | ||
writeResults(resultsTable, whichBench); | ||
|
||
resultFiles.forEach((file) => { | ||
try { | ||
fs.unlinkSync(file); | ||
} catch (error) { | ||
console.error(`Error deleting file ${file}: ${(error as Error).message}`); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.servers = exports.formattedServerNames = void 0; | ||
exports.formattedServerNames = { | ||
tailcall: "Tailcall", | ||
gqlgen: "Gqlgen", | ||
apollo: "Apollo GraphQL", | ||
netflixdgs: "Netflix DGS", | ||
caliban: "Caliban", | ||
async_graphql: "async-graphql", | ||
hasura: "Hasura", | ||
graphql_jit: "GraphQL JIT", | ||
}; | ||
exports.servers = ["apollo", "caliban", "netflixdgs", "gqlgen", "tailcall", "async_graphql", "hasura", "graphql_jit"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { FormattedServerNames } from './types'; | ||
|
||
export const formattedServerNames: FormattedServerNames = { | ||
tailcall: "Tailcall", | ||
gqlgen: "Gqlgen", | ||
apollo: "Apollo GraphQL", | ||
netflixdgs: "Netflix DGS", | ||
caliban: "Caliban", | ||
async_graphql: "async-graphql", | ||
hasura: "Hasura", | ||
graphql_jit: "GraphQL JIT", | ||
}; | ||
|
||
export const servers: string[] = ["apollo", "caliban", "netflixdgs", "gqlgen", "tailcall", "async_graphql", "hasura", "graphql_jit"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.writeMetricsDataFiles = writeMetricsDataFiles; | ||
var fileUtils_1 = require("./fileUtils"); | ||
function writeMetricsDataFiles(serverMetrics, servers) { | ||
var reqSecData = "/tmp/reqSec.dat"; | ||
var latencyData = "/tmp/latency.dat"; | ||
(0, fileUtils_1.writeDataFile)(reqSecData, "Server Value\n" + servers.map(function (server) { return "".concat(server, " ").concat(serverMetrics[server].reqSec); }).join('\n')); | ||
(0, fileUtils_1.writeDataFile)(latencyData, "Server Value\n" + servers.map(function (server) { return "".concat(server, " ").concat(serverMetrics[server].latency); }).join('\n')); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { writeDataFile } from './fileUtils'; | ||
import { ServerMetrics } from './types'; | ||
|
||
export function writeMetricsDataFiles(serverMetrics: Record<string, ServerMetrics>, servers: string[]): void { | ||
const reqSecData = "/tmp/reqSec.dat"; | ||
const latencyData = "/tmp/latency.dat"; | ||
|
||
writeDataFile(reqSecData, "Server Value\n" + servers.map(server => `${server} ${serverMetrics[server].reqSec}`).join('\n')); | ||
writeDataFile(latencyData, "Server Value\n" + servers.map(server => `${server} ${serverMetrics[server].latency}`).join('\n')); | ||
} |
Oops, something went wrong.
4c10b34
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ posts { id userId title user { id name email }}}
29,362.20
3.39
254.82x
2,000.36
50.18
17.36x
1,648.10
60.39
14.30x
1,330.08
74.81
11.54x
778.96
127.36
6.76x
368.91
220.58
3.20x
262.50
374.94
2.28x
115.23
565.87
1.00x
{ posts { title }}
57,987.30
1.71
68.87x
9,720.48
10.48
11.54x
9,478.06
10.92
11.26x
2,173.76
47.59
2.58x
1,730.98
57.69
2.06x
1,615.09
69.93
1.92x
1,358.33
73.51
1.61x
841.98
118.47
1.00x
{ greet }
67,796.20
1.07
25.61x
58,066.80
1.74
21.94x
47,524.50
2.12
17.96x
46,781.00
5.19
17.67x
8,394.70
14.69
3.17x
7,949.55
12.74
3.00x
5,225.25
19.12
1.97x
2,646.78
37.79
1.00x