measuresuite
This library measures the execution time for code. Can measure asm (with Assemblyline), o, so, bin files. Can check correctness (equality of all functions on output data) and the output is a JSON with robust cycle counts.
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (11.6%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
This library measures the execution time for code. Can measure asm (with Assemblyline), o, so, bin files. Can check correctness (equality of all functions on output data) and the output is a JSON with robust cycle counts.
Basic Info
Statistics
- Stars: 9
- Watchers: 2
- Forks: 3
- Open Issues: 5
- Releases: 1
Topics
Metadata Files
Readme.md
MeasureSuite
This library measures the execution time of code.
Features
- You can load
.o,.so,.bin,.asmfiles and out comes aJSONwith cycle counts. - Runs all loaded programs in a random order with random inputs.
- Can check if the results matches the results of a the other loaded methods.
- C-interface
- TypeScript-interface
- CLI tool
ms, takes files in and outputsJSONmeasurements - CLI script
msc, takes files in, reports relative performance toward first file. - Supports functions of the C-like type
void A(uint64_t *out, const uint64_t *in)(up to six parameters) - It assembles assembly code using AssemblyLine
- Reports chunk size counting. (i.e. How many instructions of a function beaks a chunk boundary, when assembling assemblyfiles with AssemblyLine)
- Returns a JSON string with the measurement metrics.
- Uses Performance Counters (PMC), falls back to
RDTSCif PMC are unavailable. - Installable with
npm i measuresuite
Repo Contents
This repository contains
- the C-library libmeasuresuite in lib
- a cli tool ms in bin; use like ./ms ./fileA.asm ./fileB.o, out comes JSON.
- a cli script msc in bin; use ./msc --check base.asm change_a.asm change_b.asm
- a TypeScript-Wrapper in ts, around libmeasuresuite built with node-gyp.
Build-instructions in Build.md.
Examples
Find full C and TS examples in the examples directory. Some need AssemblyLine installed.
Sneak Peak C-lib
```c
include
/* * void addtwonumbers(uint64t *out0, const uint64t *in0, const uint64t *in1) { * *out0 = *in0 + *in1; * } */ char addtwo_asm[] = {"mov rax, [rsi]\n" "add rax, [rdx]\n" "mov [rdi], rax\n" "ret\n"};
const int argwidth = 1; const int argnumout = 1; const int argnum_in = 2;
// our measuresuite handle measuresuite_t ms = NULL;
// initializing the measuresuite msinitialize(&ms, argwidth, argnumin, argnumout);
int id = -1; msloaddata(ms, // handle ASM, // type of input data is assembly (uint8t *)addtwoasm, // pointer to input data strlen(addtwoasm), // length of input data NULL, // symbol (ignored for BIN/ASM, optional for ELF, required // for SHAREDOBJECT) &id); // ID (in/out)
const int numberofbatches = 10; // 10 batches of const int batchsize = 100; // 100 iterations of the function-unter-test (addtwo_asm), each
msmeasure(ms, batchsize, numberofbatches);
const char *json = NULL; sizet len = 0; msget_json(ms, &json, &len);
assert(json != NULL); assert(len != 0);
printf("%s\n", json); // prints: // // { // "stats": { // "numFunctions": 1, // "runtime": 0, // "incorrect": 0 // }, // "functions": [ { "type": "ASM", "chunks": 0 } ], // "cycles": [ [ 1352, 890, 895, 884, 888, 886, 886, 886, 884, 888 ] ] // }
ms_terminate(ms); return 0; } ```
Sneak Peak CLI
bash
$ make ms
$ make -B -C ./examples/elf add_two_numbers.o
$ ./ms -n 3 ./examples/elf/add_two_numbers.o ./examples/elf/add_two_numbers.asm | jq
```json { "stats": { "numFunctions": 2, "runtime": 1, "incorrect": 0 }, "functions": [ { "type": "ELF" }, { "type": "ASM", "chunks": 0 } ], "cycles": [ [ 7074, 7705, 7358 ], [ 7640, 7259, 7858 ] ] }
```
Sneak Peak CLI MSC
bash
$ make ms
$ make -B -C ./examples/elf add_two_numbers.o
$ ./bin/msc ./examples/elf/add_two_numbers.asm ./examples/elf/add_two_numbers_very_slow.asm ./examples/elf/add_two_numbers.o
Cycles (#3): 2941 3027 2941
2941 / 2941 = 1.0000 (./examples/elf/add_two_numbers.asm)
3027 / 2941 = 1.0292 (./examples/elf/add_two_numbers_very_slow.asm)
2941 / 2941 = 1.0000 (./examples/elf/add_two_numbers.o)
Sneak Peak TypeScript
```ts import { type MeasureResult, Measuresuite } from "measuresuite";
/** * our assembly strings to measure, same as in ./addtwonumbers.c */
const functionA = [ "mov rax, [rsi]", "add rax, [rdx]", "mov [rdi], rax", "ret", ].join("\n");
const functionB = [ "mov rax, [rsi]", "push rbx", "mov rbx, [rdx]", "lea rax, [rbx + rax]", "mov [rdi], rax", "pop rbx", "ret", ].join("\n");
const argwidth = 1; const argnumout = 1; const argnum_in = 2;
// create a Measuresuite object const ms = new Measuresuite(argwidth, argnumin, argnum_out); ms.enableChecking();
const nob = 50; const batchSize = 10000;
// measure const measurementResult: MeasureResult | null = ms.measure(batchSize, nob, [ functionA, functionB ]);
console.log( The Measurement took ${measurementResult.stats.runtime}ms to complete);
const [functionARes, functionBRes] = measurementResult.cycles;
console.log(Function A's cycles: ${functionARes.join(",")});
console.log(Function B's cycles: ${functionBRes.join(",")});
const medianA = functionARes.sort().at(Math.floor(nob / 2)); const medianB = functionBRes.sort().at(Math.floor(nob / 2));
console.log(Function A's median: ${medianA});
console.log(Function B's median: ${medianB});
console.log(
Function A is ${medianA < medianB ? "" : "not"} faster than Function B
);
```
Acknowledgements
This project was supported by:
- The Air Force Office of Scientific Research (AFOSR) under award number FA9550-20-1-0425
- An ARC Discovery Early Career Researcher Award (project number DE200101577)
- An ARC Discovery Project (project number DP210102670)
- The Blavatnik ICRC at Tel-Aviv University
- the Defense Advanced Research Projects Agency (DARPA) and Air Force Research Laboratory (AFRL) under contracts FA8750-19-C-0531 and HR001120C0087
- the National Science Foundation under grant CNS-1954712
- Gifts from AMD, Google, and Intel
Owner
- Name: 0xADE1A1DE
- Login: 0xADE1A1DE
- Kind: organization
- Repositories: 5
- Profile: https://github.com/0xADE1A1DE
Citation (CITATION.cff)
cff-version: 1.2.0 message: "If you use this software, please cite it as below." authors: - family-names: "Kuepper" given-names: "Joel" orchid: "https://orcid.org/0000-0002-0643-2440" - family-names: "Wu" given-names: "David" - family-names: "Yarom" given-names: "Yuval" title: "MeasureSuite: Robustly measure execution time of x86 assembly" date-released: 2022-08-01 url: "https://github.com/0xADE1A1DE/MeasureSuite"
GitHub Events
Total
- Watch event: 1
- Fork event: 1
Last Year
- Watch event: 1
- Fork event: 1
Committers
Last synced: 8 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Joel | r****v@g****m | 268 |
| dependabot[bot] | 4****] | 131 |
| javali7 | j****7 | 2 |
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 0
- Total pull requests: 196
- Average time to close issues: N/A
- Average time to close pull requests: 4 days
- Total issue authors: 0
- Total pull request authors: 1
- Average comments per issue: 0
- Average comments per pull request: 0.45
- Merged pull requests: 104
- Bot issues: 0
- Bot pull requests: 196
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
- dependabot[bot] (181)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- npm 104 last-month
- Total dependent packages: 1
- Total dependent repositories: 1
- Total versions: 22
- Total maintainers: 1
npmjs.org: measuresuite
Typescript wrapper around libmeasuresuite
- Homepage: https://github.com/0xADE1A1DE/MeasureSuite#readme
- License: Apache-2.0
-
Latest release: 2.2.2
published over 2 years ago
Rankings
Maintainers (1)
Dependencies
- 326 dependencies
- @rollup/plugin-typescript ^8.3.4 development
- @types/lodash-es ^4.17.6 development
- @types/node ^18.6.3 development
- @typescript-eslint/eslint-plugin ^5.33.0 development
- @typescript-eslint/parser ^5.33.0 development
- c8 ^7.12.0 development
- eslint ^8.21.0 development
- eslint-config-prettier ^8.5.0 development
- eslint-plugin-prettier ^4.2.1 development
- node-gyp ^9.1.0 development
- prettier ^2.7.1 development
- rollup ^2.77.2 development
- rollup-plugin-copy ^3.4.0 development
- rollup-plugin-dts ^4.2.2 development
- ts-node ^10.9.1 development
- typescript ^4.7.4 development
- vite ^3.0.4 development
- vitest ^0.21.0 development
- lodash-es ^4.17.21
- measureaddon file:./dist/measureaddon.node
- dependabot/fetch-metadata v1.1.1 composite
- 0xADE1A1DE/AssemblyLine main composite
- actions/checkout v3 composite
- actions/checkout v3 composite
- irongut/CodeCoverageSummary v1.2.0 composite
- jwalton/gh-find-current-pr v1 composite
- marocchino/sticky-pull-request-comment v2 composite
- 0xADE1A1DE/AssemblyLine main composite
- actions/checkout v3 composite
- irongut/CodeCoverageSummary v1.2.0 composite
- jwalton/gh-find-current-pr v1 composite
- marocchino/sticky-pull-request-comment v2 composite
- 0xADE1A1DE/AssemblyLine main composite
- actions/checkout v3 composite
- actions/setup-node v3 composite
- cpp-linter/cpp-linter-action v2 composite
- jidicula/clang-format-action v4.10.1 composite
- 0xADE1A1DE/AssemblyLine main composite
- actions/checkout v3 composite
- actions/setup-node v3 composite
- irongut/CodeCoverageSummary v1.2.0 composite
- jwalton/gh-find-current-pr v1 composite
- marocchino/sticky-pull-request-comment v2 composite
- actions/checkout v3 composite
- actions/setup-node v3 composite
- typescript 4.9.4 development
- ../.. 2.0.0-rc.2
- ../../..
- ../../ts 2.0.0-rc.1
- measuresuite
- typescript ^4.9.4 development
- measuresuite file:../../
- @types/node 18.11.18 development
- typescript 4.9.4 development
- ../.. 2.0.0-rc.2
- ../../ts 2.0.0-rc.1
- measuresuite
- @types/node ^18.11.18 development
- typescript ^4.9.4 development
- measuresuite file:../..