-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1373 from o1-labs/perf/field-inverse
Faster TS field inverse
- Loading branch information
Showing
8 changed files
with
42 additions
and
14 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
Submodule bindings
updated
2 files
+37 −0 | crypto/benchmarks/inverse.ts | |
+131 −2 | crypto/finite_field.ts |
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 |
---|---|---|
@@ -1,21 +1,21 @@ | ||
/** | ||
* Helper for printing timings, in the spirit of Python's `tic` and `toc`. | ||
* | ||
* This is a slightly nicer version of './tic-tic.ts' which only works in Node. | ||
* This is a slightly nicer version of './tic-toc.ts' which only works in Node. | ||
*/ | ||
|
||
export { tic, toc }; | ||
|
||
let timingStack: [string, number][] = []; | ||
let i = 0; | ||
let timingStack: [string | undefined, number][] = []; | ||
|
||
function tic(label = `Run command ${i++}`) { | ||
process.stdout.write(`${label}... `); | ||
function tic(label?: string) { | ||
if (label) process.stdout.write(`${label}... `); | ||
timingStack.push([label, performance.now()]); | ||
} | ||
|
||
function toc() { | ||
let [label, start] = timingStack.pop()!; | ||
let time = (performance.now() - start) / 1000; | ||
process.stdout.write(`\r${label}... ${time.toFixed(3)} sec\n`); | ||
if (label) process.stdout.write(`\r${label}... ${time.toFixed(3)} sec\n`); | ||
return time; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export { assert }; | ||
|
||
function assert(stmt: boolean, message?: string): asserts stmt { | ||
if (!stmt) { | ||
throw Error(message ?? 'Assertion failed'); | ||
} | ||
} |
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,18 @@ | ||
/** | ||
* Helper for printing timings, in the spirit of Python's `tic` and `toc`. | ||
*/ | ||
|
||
export { tic, toc }; | ||
|
||
let timingStack: [string | undefined, number][] = []; | ||
|
||
function tic(label?: string) { | ||
timingStack.push([label, performance.now()]); | ||
} | ||
|
||
function toc() { | ||
let [label, start] = timingStack.pop()!; | ||
let time = (performance.now() - start) / 1000; | ||
if (label) console.log(`${label}... ${time.toFixed(3)} sec`); | ||
return time; | ||
} |
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