Skip to content

Commit 7deffeb

Browse files
author
ts-benchmark
committed
Add test for auto typed approach.
1 parent 547680d commit 7deffeb

File tree

4 files changed

+64
-1
lines changed

4 files changed

+64
-1
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: TypeScript Benchmark "auto-typed-mongoose"
2+
on:
3+
pull_request:
4+
paths:
5+
- ".github/workflows/benchmark.yml"
6+
- "package.json"
7+
- "types/**"
8+
- "benchmarks/typescript/**"
9+
push:
10+
branches:
11+
- master
12+
paths:
13+
- ".github/workflows/benchmark.yml"
14+
- "package.json"
15+
- "types/**"
16+
- "benchmarks/typescript/**"
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
typescript:
22+
runs-on: ubuntu-20.04
23+
name: Benchmark TypeScript Types
24+
steps:
25+
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
26+
with:
27+
fetch-depth: 0
28+
- name: Setup node
29+
uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93 # v3.4.1
30+
with:
31+
node-version: 16
32+
33+
- run: npm install
34+
35+
- run: npx ts-benchmark -p ./benchmarks/typescript/auto-typed -f 17/100000 18 29 32 -g -t --colors
36+
env:
37+
DB_URL: ${{ secrets.DB_URL }}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Schema, Model, model } from 'mongoose';
2+
3+
const schema = new Schema({
4+
name: { type: String, required: true },
5+
email: { type: String, required: true },
6+
avatar: String
7+
});
8+
9+
const UserModel = model('User', schema);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"compilerOptions": {
3+
"allowSyntheticDefaultImports": true,
4+
"baseUrl": ".",
5+
"paths": {
6+
"mongoose": ["../../../"]
7+
}
8+
},
9+
"esModuleInterop": true,
10+
"outDir": "typescript",
11+
"strictNullChecks": true,
12+
"include": [
13+
"./*.ts",
14+
"../../../index.d.ts"
15+
]
16+
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@
9999
"tdd": "mocha ./test/*.test.js --inspect --watch --recursive --watch-files ./**/*.{js,ts}",
100100
"test-coverage": "nyc --reporter=html --reporter=text npm test",
101101
"ts-benchmark": "ts-benchmark -p ./benchmarks/typescript/simple -f 17/100000 18 29 32",
102-
"ts-benchmark-watch": "ts-benchmark -p ./benchmarks/typescript/simple -w ./types -i -s -f 17/100000 18 29 32 -b master"
102+
"ts-benchmark-watch": "ts-benchmark -p ./benchmarks/typescript/simple -w ./types -i -s -f 17/100000 18 29 32 -b master",
103+
"ts-benchmark-auto": "ts-benchmark -p ./benchmarks/typescript/auto-typed -f 17/100000 18 29 32"
103104
},
104105
"main": "./index.js",
105106
"types": "./types/index.d.ts",

0 commit comments

Comments
 (0)