Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test benchmarks (will not be merged) #134

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion codegen/testgen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ export function generateTestCode(shards: OverloadShard[]): string {
import { createInstances } from '../instance';
import { getSigners } from '../signers';

let testsBegin: Date

`);

shards.forEach((os) => {
Expand Down Expand Up @@ -107,14 +109,22 @@ async function deployTfheTestFixture${os.shardNumber}(): Promise<TFHETestSuite${
});

res.push(`
testsBegin = new Date();
});

after(function() {
const testsEnd = new Date();
const diffMs = testsEnd.getTime() - testsBegin.getTime();
console.log('Tests finished in ' + diffMs + 'ms');
});
`);

// don't allow user to add test for method that doesn't exist
const overloadUsages: { [methodName: string]: boolean } = {};
shards.forEach((os) => {
os.overloads.forEach((o) => {
const testName = `test operator "${o.name}" overload ${signatureContractEncryptedSignature(o)}`;
const overloadSignature = signatureContractEncryptedSignature(o);
const testName = `test operator "${o.name}" overload ${overloadSignature}`;
const methodName = signatureContractMethodName(o);
overloadUsages[methodName] = true;
const tests = overloadTests[methodName] || [];
Expand All @@ -132,7 +142,10 @@ async function deployTfheTestFixture${os.shardNumber}(): Promise<TFHETestSuite${
const testArgs = t.inputs.join(', ');
res.push(`
it('${testName} test ${testIndex} (${testArgs})', async function () {
const testBegin = new Date();
const res = await this.contract${os.shardNumber}.${methodName}(${testArgs});
const testDurationMs = new Date().getTime() - testBegin.getTime();
console.log('test,"${methodName}(${overloadSignature}) inputs (${testArgs})",' + testDurationMs);
expect(res).to.equal(${t.output});
});
`);
Expand Down
Loading