Skip to content
This repository was archived by the owner on Nov 4, 2021. It is now read-only.
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
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,9 @@ jobs:
DATABASE_URL: 'postgres://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres'
REDIS_URL: 'redis://localhost'
run: yarn task:db-init && yarn test

- name: Run benchmarks
env:
DATABASE_URL: 'postgres://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres'
REDIS_URL: 'redis://localhost'
run: yarn task:db-init && yarn benchmark
4 changes: 2 additions & 2 deletions tests/worker.test.ts → benchmarks/worker.benchmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { makePiscina } from '../src/worker/piscina'
import { defaultConfig } from '../src/config'
import { PluginEvent } from 'posthog-plugins/src/types'
import { performance } from 'perf_hooks'
import { mockJestWithIndex } from './helpers/plugins'
import { mockJestWithIndex } from '../tests/helpers/plugins'
import * as os from 'os'
import { LogLevel } from '../src/types'

Expand Down Expand Up @@ -71,7 +71,7 @@ function setupPiscina(workers: number, code: string, tasksPerWorker: number) {
})
}

test('piscina worker test', async () => {
test('piscina worker benchmark', async () => {
// Uncomment this to become a 10x developer and make the test run just as fast!
// Reduces events by 10x and limits threads to max 8 for quicker development
const isLightDevRun = false
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ module.exports = {
clearMocks: true,
coverageProvider: 'v8',
setupFilesAfterEnv: ['./jest.setup.pg-mock.js', './jest.setup.redis-mock.js', './jest.setup.fetch-mock.js'],
testMatch: ['<rootDir>/tests/**/*.test.ts'],
testMatch: ['<rootDir>/tests/**/*.test.ts', '<rootDir>/benchmarks/**/*.benchmark.ts'],
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"types": "dist/src/index.d.ts",
"main": "dist/src/index.js",
"scripts": {
"test": "jest --runInBand",
"test": "jest --testPathIgnorePatterns='benchmarks/'",
"benchmark": "jest --runInBand benchmarks/",
"start": "yarn start:dev",
"start:dist": "node dist/src/index.js --base-dir ../posthog",
"start:dev": "ts-node-dev --exit-child src/index.ts --base-dir ../posthog",
Expand Down