diff --git a/test/performance/charts/.gitignore b/test/performance/charts/.gitignore new file mode 100644 index 000000000..a6c7c2852 --- /dev/null +++ b/test/performance/charts/.gitignore @@ -0,0 +1 @@ +*.js diff --git a/test/performance/charts/index.js b/test/performance/charts/index.js deleted file mode 100644 index c946da8fa..000000000 --- a/test/performance/charts/index.js +++ /dev/null @@ -1,52 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const fs = __importStar(require("fs")); -require("chartjs-to-image"); -const graphs_1 = require("./src/graphs"); -const main = () => __awaiter(void 0, void 0, void 0, function* () { - let buffer = fs.readFileSync('../report/report.json', 'utf-8'); - let reports = JSON.parse(buffer); - yield (0, graphs_1.exportTPSGraph)({ - output: '../report/tps.png', - }, reports); - yield (0, graphs_1.exportDatabaseStats)('../report/database_connections.png', reports); - const ps = ['P99', 'P95', 'P75', 'Avg']; - for (let p of ps) { - yield (0, graphs_1.exportLatencyGraph)({ - output: '../report/' + p.toLowerCase() + '.png' - }, p, reports); - } -}); -main(); diff --git a/test/performance/charts/src/colors.js b/test/performance/charts/src/colors.js deleted file mode 100644 index a66518a80..000000000 --- a/test/performance/charts/src/colors.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.NAMED_COLORS = exports.CHART_COLORS = void 0; -exports.CHART_COLORS = { - red: 'rgb(255, 99, 132)', - orange: 'rgb(255, 159, 64)', - yellow: 'rgb(255, 205, 86)', - green: 'rgb(75, 192, 192)', - blue: 'rgb(54, 162, 235)', - purple: 'rgb(153, 102, 255)', - grey: 'rgb(201, 203, 207)' -}; -exports.NAMED_COLORS = [ - exports.CHART_COLORS.red, - exports.CHART_COLORS.orange, - exports.CHART_COLORS.yellow, - exports.CHART_COLORS.green, - exports.CHART_COLORS.blue, - exports.CHART_COLORS.purple, - exports.CHART_COLORS.grey, -]; diff --git a/test/performance/charts/src/graphs.js b/test/performance/charts/src/graphs.js deleted file mode 100644 index b85630917..000000000 --- a/test/performance/charts/src/graphs.js +++ /dev/null @@ -1,190 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.exportDatabaseStats = exports.exportLatencyGraph = exports.exportTPSGraph = void 0; -const colors_1 = require("./colors"); -const chartjs_to_image_1 = __importDefault(require("chartjs-to-image")); -const chart_js_1 = require("chart.js"); -const chartjs_plugin_annotation_1 = __importDefault(require("chartjs-plugin-annotation")); -chart_js_1.Chart.register(chartjs_plugin_annotation_1.default); -const exportTPSGraph = (configuration, result) => __awaiter(void 0, void 0, void 0, function* () { - const scripts = []; - for (let script in result) { - scripts.push(script); - } - const reportsForAnyScript = result[scripts[0]]; - if (!reportsForAnyScript) { - throw new Error("no data"); - } - const datasets = scripts.map(((script, index) => { - return { - label: script, - data: result[script].map(r => r.TPS), - backgroundColor: colors_1.NAMED_COLORS[index % scripts.length], - }; - })); - const config = { - type: 'bar', - data: { - labels: reportsForAnyScript - .map(r => r.Configuration.Name), - datasets: datasets - }, - options: { - plugins: { - title: { - display: true, - text: 'TPS' - }, - }, - responsive: true, - interaction: { - intersect: false, - }, - scales: { - x: { - stacked: true, - }, - y: { - stacked: true - } - } - } - }; - const chart = new chartjs_to_image_1.default(); - chart.setConfig(config); - yield chart.toFile(configuration.output); -}); -exports.exportTPSGraph = exportTPSGraph; -const exportLatencyGraph = (configuration, key, result) => __awaiter(void 0, void 0, void 0, function* () { - const scripts = []; - for (let script in result) { - scripts.push(script); - } - const reportsForAnyScript = result[scripts[0]]; - if (!reportsForAnyScript) { - throw new Error("no data"); - } - const datasets = scripts.map(((script, index) => { - return { - label: script, - data: result[script].map(r => parseFloat(r.Metrics.Time[key].substring(0, r.Metrics.Time[key].length - 2))), - backgroundColor: colors_1.NAMED_COLORS[index % scripts.length], - }; - })); - const config = { - type: 'bar', - data: { - labels: reportsForAnyScript - .map(r => r.Configuration.Name), - datasets: datasets - }, - options: { - plugins: { - title: { - display: true, - text: 'TPS' - }, - }, - interaction: { - intersect: false, - }, - scales: { - x: { - stacked: true, - }, - y: { - stacked: true - } - } - } - }; - const chart = new chartjs_to_image_1.default(); - chart.setConfig(config); - yield chart.toFile(configuration.output); -}); -exports.exportLatencyGraph = exportLatencyGraph; -const exportDatabaseStats = (output, result) => __awaiter(void 0, void 0, void 0, function* () { - const scope = 'github.com/uptrace/opentelemetry-go-extra/otelsql'; - const scripts = []; - for (let script in result) { - scripts.push(script); - } - const reportsForAnyScript = result[scripts[0]]; - if (!reportsForAnyScript) { - throw new Error("no data"); - } - const datasets = scripts.map(((script, index) => { - return { - label: script, - data: result[script].map(r => r.InternalMetrics.ScopeMetrics - .find(scopeMetric => scopeMetric.Scope.Name == scope) - .Metrics - .find(metric => metric.Name == 'go.sql.connections_open') - .Data - .DataPoints[0] - .Value), - backgroundColor: colors_1.NAMED_COLORS[index % scripts.length], - }; - })); - const maxConnection = reportsForAnyScript[0].InternalMetrics.ScopeMetrics - .find(scopeMetric => scopeMetric.Scope.Name == scope) - .Metrics - .find(metric => metric.Name == 'go.sql.connections_max_open') - .Data - .DataPoints[0] - .Value; - const config = { - type: 'bar', - data: { - labels: reportsForAnyScript.map(r => r.Configuration.Name), - datasets: datasets - }, - options: { - plugins: { - title: { - display: true, - text: 'Database connections' - }, - annotation: { - annotations: { - line1: { - type: 'line', - yMin: maxConnection, - yMax: maxConnection, - borderColor: 'rgb(255, 99, 132)', - borderWidth: 2, - } - } - } - }, - interaction: { - intersect: false, - }, - scales: { - x: { - stacked: false, - }, - y: { - stacked: false - } - } - } - }; - const chart = new chartjs_to_image_1.default(); - chart.setConfig(config); - chart.setChartJsVersion('4'); - yield chart.toFile(output); -}); -exports.exportDatabaseStats = exportDatabaseStats; diff --git a/test/performance/charts/src/report.js b/test/performance/charts/src/report.js deleted file mode 100644 index 3918c74e4..000000000 --- a/test/performance/charts/src/report.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/test/performance/justfile b/test/performance/justfile index 464c38f5c..45149377e 100755 --- a/test/performance/justfile +++ b/test/performance/justfile @@ -15,6 +15,7 @@ run bench='.' p='1' benchtime='1s' count='1' ledger-url='' output='./report/benc -test.benchtime {{benchtime}} . | tee -a {{output}} compare bench='.' p='1' benchtime='1s' count='1' output='./report/benchmark-output.txt': + trap 'rm -rf {{tmpdir}}' EXIT just run {{bench}} {{p}} {{benchtime}} {{count}} '' './report/benchmark-output-local.txt' git clone --depth 1 -b main https://github.com/formancehq/ledger {{tmpdir}} go test -run ^$ -tags it,local -report.file \