-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve performance more by computing array size
- Loading branch information
1 parent
399a28c
commit 3e54e0d
Showing
6 changed files
with
102 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import sql, { Sql } from "../src/index"; | ||
import bytes from "bytes"; | ||
|
||
const before = process.memoryUsage(); | ||
console.log(`before: ${bytes(before.heapUsed)} / ${bytes(before.heapTotal)}`); | ||
const start = process.hrtime(); | ||
|
||
const queries: Sql[] = []; | ||
|
||
for (let i = 0; i < 1_000_000; i++) { | ||
const subQuery = `something ${"goes"} here and ${"there"}`; | ||
const query = sql`this is ${"the"} query: ${i}, ${subQuery}`; | ||
queries.push(query); | ||
|
||
// Compute properties for perf testing. | ||
query.text; | ||
query.values; | ||
} | ||
|
||
const end = process.hrtime(start); | ||
const after = process.memoryUsage(); | ||
console.log(`after: ${bytes(after.heapUsed)} / ${bytes(after.heapTotal)}`); | ||
console.log(`difference: ${bytes(after.heapUsed - before.heapUsed)}`); | ||
console.log(`time: ${end[0]}s ${~~(end[1] / 1000000)}ms`); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters