Skip to content

Instantly share code, notes, and snippets.

@trkoch
Last active January 30, 2021 19:26
Show Gist options
  • Save trkoch/66933818d965069b0f8dccce19690460 to your computer and use it in GitHub Desktop.
Save trkoch/66933818d965069b0f8dccce19690460 to your computer and use it in GitHub Desktop.
fast-diff sqlite3.c amalgamation
#!/usr/bin/env node
const fs = require('fs/promises')
const diff = require('fast-diff')
async function main() {
const startAll = process.hrtime.bigint()
const startRead = process.hrtime.bigint()
// Download from https://www.sqlite.org/2021/sqlite-autoconf-3340100.tar.gz
const fileA = await fs.readFile('sqlite3-a.c', {encoding: 'utf8'})
const fileB = await fs.readFile('sqlite3-b.c', {encoding: 'utf8'})
const endRead = process.hrtime.bigint()
console.log(`Read took ${(endRead - startRead)/BigInt(1e6)} milliseconds`)
const startDiff = process.hrtime.bigint()
console.log(diff(fileA, fileB)[1])
const endDiff = process.hrtime.bigint()
console.log(`Diff took ${(endDiff - startDiff)/BigInt(1e6)} milliseconds`)
const endAll = process.hrtime.bigint()
console.log(`Benchmark took ${(endAll - startAll)/BigInt(1e6)} milliseconds`)
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment