-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
27 lines (22 loc) · 1004 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { test } from 'uvu'
// import * as assert from 'uvu/assert'
import { search } from '../src/index'
const sqliteDir = (process.env.SQLITE_DIR || __dirname + '/../data').toString()
function stats () {
const memoryUsage = process.memoryUsage()
const cpuUsage = process.cpuUsage()
console.log('Memory Usage:')
console.log(`- RSS: ${memoryUsage.rss / 1024 / 1024} MB`) // Resident Set Size
console.log(`- Heap Total: ${memoryUsage.heapTotal / 1024 / 1024} MB`)
console.log(`- Heap Used: ${memoryUsage.heapUsed / 1024 / 1024} MB`)
console.log(`- External: ${memoryUsage.external / 1024 / 1024} MB`)
console.log(`- User CPU Time: ${cpuUsage.user / 1000} ms`)
console.log(`- System CPU Time: ${cpuUsage.system / 1000} ms`)
}
test('Reads', async () => {
const result = await search('events', `entities LIKE '%king%'`, sqliteDir, (dbPath, current, total, rows) => {
console.log(`${dbPath} (${(current / total * 100).toFixed(2)}%) - ${rows.length}`)
stats()
})
})
test.run()