This commit is contained in:
sinclair
2025-12-24 15:44:34 +09:00
commit 13d553220c
1047 changed files with 80931 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
import { shell } from '@sinclair/hammer'
import { statSync, readdirSync } from 'fs'
import { basename, extname } from 'path'
export async function measure(test: string) {
await shell(`hammer build task/benchmark/compression/module/${test}.ts --dist target/benchmark/compression`)
const compiled = statSync(`target/benchmark/compression/${test}.js`)
await shell(`hammer build task/benchmark/compression/module/${test}.ts --dist target/benchmark/compression --minify`)
const minified = statSync(`target/benchmark/compression/${test}.js`)
return {
test: test.padEnd(20),
compiled: `${(compiled.size / 1000).toFixed(1)} kb`.padStart(8),
minified: `${(minified.size / 1000).toFixed(1)} kb`.padStart(8),
ratio: compiled.size / minified.size,
}
}
export async function compression() {
const tests = readdirSync('task/benchmark/compression/module').map((name) => basename(name, extname(name)))
const results = await Promise.all(tests.map((test) => measure(test)))
const present = results.reduce((acc, c) => {
return { ...acc, [c.test.replace(/-/g, '/')]: { Compiled: c.compiled, Minified: c.minified, Compression: `${c.ratio.toFixed(2)} x` } }
}, {})
console.table(present)
}

View File

@@ -0,0 +1,3 @@
import { TypeCompiler } from '@sinclair/typebox/compiler'
console.log(TypeCompiler)

View File

@@ -0,0 +1,3 @@
import * as Errors from '@sinclair/typebox/errors'
console.log(Errors)

View File

@@ -0,0 +1,3 @@
import * as Syntax from '@sinclair/typebox/syntax'
console.log(Syntax)

View File

@@ -0,0 +1,3 @@
import { TypeSystem } from '@sinclair/typebox/system'
console.log(TypeSystem)

View File

@@ -0,0 +1,3 @@
import { Value } from '@sinclair/typebox/value'
console.log(Value)

View File

@@ -0,0 +1,3 @@
import { Type } from '@sinclair/typebox'
const T = Type.String()