Skip to content

Commit 513a43a

Browse files
committed
Move benchmark and translate into tools folder
1 parent f974337 commit 513a43a

File tree

14 files changed

+45
-29
lines changed

14 files changed

+45
-29
lines changed

.npmignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ src/
44
tests/
55
.editorconfig
66
.eslintcache
7-
.eslintignore
8-
.eslintrc.json
97
.gitattributes
108
.gitignore
119
.nvmrc
1210
.prettierignore
1311
.prettierrc.json
14-
docker-compose.yml
12+
eslint.config.mjs
1513
tsconfig.json

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ profanity.whitelist.removeWords(['arsenic', 'buttress']);
164164

165165
## Benchmarking ⏱️
166166

167-
To see how Profanity performs, check out our [benchmark results](./src/benchmark/results.md).
167+
To see how Profanity performs, check out our [benchmark results](./src/tools/benchmark/results.md).
168168

169169
## Contributing 🤝
170170

contribute.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ We utilize a self-hosted instance of the Open Source [LibreTranslate](https://gi
7676
#### Steps to Run Translations
7777

7878
1. Open a terminal.
79-
2. Start Docker: `docker-compose up`.
80-
3. Run the translation script: `npm run translate`.
79+
2. Generate translations: `npm run translate`.
8180

8281
#### Available Languages
8382

@@ -90,7 +89,7 @@ By default, the LibreTranslate service is configured to include all available ta
9089
To optimize performance, we limit the target languages by configuring the `LT_LOAD_ONLY` environment variable:
9190

9291
##### Configure Target Languages
93-
1. Open the `./docker-compose.yml` file.
92+
1. Open the [docker-compose.yml](./src/tools/translate/docker-compose.yml) file.
9493
2. Add a comma-separated list of the [supported language codes](https://github.com/argosopentech/argos-translate/blob/master/argostranslate/languages.csv) you wish to include. Ensure English (`en`) is included, as it serves as the source language.
9594

9695
**Example Configuration:**
@@ -112,9 +111,11 @@ Deployments to Prod consist of building and publishing the Profanity lib to NPM,
112111
2. Increment the version in package.json, using semantic versioning (e.g., `1.1.0`).
113112
3. Perform benchmarking:
114113
1. Run the script: `npm run benchmark`.
115-
2. Record the results in [benchmark/results.md](./src/benchmark/results.md), for the new version.
114+
2. Record the results in [benchmark/results.md](./src/tools/benchmark/results.md), for the new version.
116115
4. Rebuild package-lock, to pick up the new version number: `npm i --package-lock-only`.
117-
5. Push changes:
116+
5. Create local NPM package: `npm pack`
117+
- Examine generated tar file to ensure it looks healthy
118+
6. Push changes:
118119
```
119120
git add .
120121
git commit -m "Bump version to 1.1.0"

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
"pretest": "npm run build",
1818
"test": "mocha -r ts-node/register tests/**/*.spec.ts",
1919
"test:watch": "npm run test -- --watch",
20-
"benchmark": "docker-compose -f ./src/benchmark/docker-compose.yml up --build",
2120
"lint": "eslint . --cache",
2221
"lint:fix": "eslint . --fix",
2322
"format": "prettier . --write",
2423
"prepublishOnly": "npm run lint && npm test",
2524
"prepare": "husky",
26-
"translate": "ts-node src/scripts/translate.ts"
25+
"translate": "docker-compose -f ./src/tools/translate/docker-compose.yml up -d && ts-node ./src/tools/translate/translate.ts && docker-compose -f ./src/tools/translate/docker-compose.yml down",
26+
"benchmark": "docker-compose -f ./src/tools/benchmark/docker-compose.yml up --build"
2727
},
2828
"repository": {
2929
"type": "git",

src/benchmark/Dockerfile

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/tools/benchmark/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM node:20.17-alpine3.19
2+
3+
WORKDIR /app
4+
5+
COPY ../../../package*.json ./
6+
7+
RUN npm install
8+
9+
COPY ../../../ ./
10+
11+
CMD ["npx", "ts-node", "src/tools/benchmark/benchmark.ts"]
File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import * as path from "path";
1515
import { Suite, Event } from "benchmark";
1616

1717
import { VersionData, TestData } from "./benchmark-interfaces";
18-
import { Profanity, CensorType } from "..";
18+
import { Profanity, CensorType } from "../../";
1919

2020
const TEST_VERSION: number = 1;
2121

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
services:
22
benchmark:
33
build:
4-
context: ../..
5-
dockerfile: ./src/benchmark/Dockerfile
4+
context: ../../../
5+
dockerfile: ./src/tools/benchmark/Dockerfile
66
deploy:
77
resources:
88
limits:
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,23 @@
88

99
### Benchmarks
1010

11+
#### v3.1.1
12+
```
13+
benchmark-1 | Using test data: v1
14+
benchmark-1 | exists() - small clean text x 2,559,368 ops/sec ±2.95% (92 runs sampled)
15+
benchmark-1 | exists() - small profane text x 1,941,051 ops/sec ±5.64% (79 runs sampled)
16+
benchmark-1 | exists() - large clean text x 44,904 ops/sec ±5.60% (90 runs sampled)
17+
benchmark-1 | exists() - large profane text x 816,615 ops/sec ±0.74% (96 runs sampled)
18+
benchmark-1 | exists() - partial match, small profane text x 1,853,445 ops/sec ±28.20% (92 runs sampled)
19+
benchmark-1 | censor() - Word, small profane text x 1,559,873 ops/sec ±2.07% (94 runs sampled)
20+
benchmark-1 | censor() - FirstChar, small profane text x 1,548,998 ops/sec ±6.01% (96 runs sampled)
21+
benchmark-1 | censor() - FirstVowel, small profane text x 1,093,426 ops/sec ±5.54% (89 runs sampled)
22+
benchmark-1 | censor() - AllVowels, small profane text x 1,098,984 ops/sec ±0.64% (91 runs sampled)
23+
benchmark-1 | censor() - Word, large profane text x 1,633 ops/sec ±6.12% (91 runs sampled)
24+
benchmark-1 | censor() - partial match, Word, small profane text x 1,334,764 ops/sec ±5.43% (91 runs sampled)
25+
benchmark-1 | Fastest: exists() - small clean text
26+
```
27+
1128
#### v3.0.1
1229
```
1330
benchmark-1 | Using test data: v1

0 commit comments

Comments
 (0)