Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix chartjs init for benchmark #191

Merged
merged 4 commits into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@ RUN apt-get update && apt-get install -y \
libfontconfig1-dev \
libpq-dev

# Copy only package.json to enable caching
COPY ./package.json ./package-lock.json /project/
# Copy only package*.json, which are likely unchanged, allowing caching
COPY package.json package-lock.json /project/
COPY patches /project/patches

# Set the working dir to the project & install and compile all dependency
WORKDIR /project/

RUN SKIP_COMPILE=true npm ci --ignore-scripts=false --foreground-scripts

# all of the project files will be copyed to a new dir called project
COPY . /project
# copy all files, which likely have changed, and prevent caching
COPY . /project/

RUN npm run compile
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/backend/compare/charts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ const marginTopWithTitle = 34;
const marginBottom = 28;
const perEntryHeight = 34;

export function initChartJS(): void {
/** Register all standard plugins. This is for convenience. */
function initChartJS(): void {
Chart.register(...registerables);
}
initChartJS();

function calculatePlotHeight(title: string | null, data: ChangeData): number {
const result = marginBottom + data.labels.length * perEntryHeight;
Expand Down
2 changes: 0 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ import {
} from './backend/rebench/results.js';
import { setTimeout } from 'node:timers/promises';
import { reportConnectionRefused } from './shared/errors.js';
import { initChartJS } from './backend/compare/charts.js';

log.info('Starting ReBenchDB Version ' + rebenchVersion);

Expand Down Expand Up @@ -218,7 +217,6 @@ async function tryToConnect(n: number): Promise<boolean> {
}

await initPerfTracker(db);
initChartJS();

log.info(`Starting server on http://localhost:${siteConfig.port}`);
app.listen(siteConfig.port);
Expand Down
2 changes: 0 additions & 2 deletions tests/backend/compare/charts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
import { robustPath } from '../../../src/backend/util.js';
import {
createCanvas,
initChartJS,
renderInlinePlot,
renderOverviewPlots
} from '../../../src/backend/compare/charts.js';
Expand All @@ -26,7 +25,6 @@ import {
} from '../../payload.js';

initJestMatchers();
initChartJS();

const outputFolder = isRequestedToUpdateExpectedData()
? robustPath('../tests/data/expected-results/charts')
Expand Down
2 changes: 0 additions & 2 deletions tests/backend/compare/compare-view.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ import {
loadCompareViewJsSomPayload,
loadCompareViewTSomPayload
} from '../../payload.js';
import { initChartJS } from '../../../src/backend/compare/charts.js';

initJestMatchers();
initChartJS();

const dataJsSOM = loadCompareViewJsSomPayload();
const dataTruffleSOM = loadCompareViewTSomPayload();
Expand Down
2 changes: 0 additions & 2 deletions tests/backend/compare/prep-data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,8 @@ import {
loadCompareViewJsSomPayload,
loadCompareViewTSomPayload
} from '../../payload.js';
import { initChartJS } from '../../../src/backend/compare/charts.js';

initJestMatchers();
initChartJS();

describe('compareStringOrNull()', () => {
it('should compare null and null', () => {
Expand Down