Skip to content
This repository has been archived by the owner on Mar 18, 2022. It is now read-only.

Commit

Permalink
Merge ebef2cf into 3595554
Browse files Browse the repository at this point in the history
  • Loading branch information
twoeths authored Aug 10, 2021
2 parents 3595554 + ebef2cf commit 07003a2
Show file tree
Hide file tree
Showing 9 changed files with 1,307 additions and 335 deletions.
68 changes: 46 additions & 22 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,58 @@
name: Benchmark.js Example
name: Benchmark

# only one can tun at a time.
# Actions access a common cache entry and may corrupt it.
concurrency: cd-benchmark-${{ github.ref }}

on:
push:
branches:
- master
- benchmark
- benchmark # For debugging
pull_request:
branches:
- master

jobs:
benchmark:
name: Run JavaScript benchmark example
run:
runs-on: ubuntu-latest
# Don't run on forks. Forks don't have access to the S3 credentials and the workflow will fail
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}

steps:
# <common-build> - Uses YAML anchors in the future
- uses: actions/checkout@v2
- uses: actions/setup-node@v2-beta
with:
node-version: "12.14.1"
- name: Build
run: yarn
- name: Run benchmark
run: node test/bench.js | tee benchmark.txt
- name: Store benchmark result
uses: rhysd/github-action-benchmark@v1
node-version: "14.16.0"
- name: Restore dependencies
uses: actions/cache@master
id: cache-deps
with:
name: as-sha256 Benchmark
tool: "benchmarkjs"
output-file-path: benchmark.txt
# Use personal access token instead of GITHUB_TOKEN due to https://git.luolix.topmunity/t5/GitHub-Actions/Github-action-not-triggering-gh-pages-upon-push/td-p/26869/highlight/false
github-token: ${{ secrets.GH_PAGES_TOKEN }}
auto-push: true
# Show alert with commit comment on detecting possible performance regression
alert-threshold: "200%"
comment-on-alert: true
fail-on-alert: true
alert-comment-cc-users: "@wemeetagain"
path: |
node_modules
packages/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-ignore-optional-14.16.0
- name: Install & build
if: steps.cache-deps.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile --ignore-optional
- name: Build
run: yarn build
if: steps.cache-deps.outputs.cache-hit == 'true'
# </common-build>

- name: Run benchmarks
run: yarn benchmark
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# benchmark options
BENCHMARK_S3: true
BENCHMARK_threshold: 3
# S3 credentials
S3_ACCESS_KEY: ${{ secrets.S3_BENCH_LODESTAR_ACCESS_KEY }}
S3_SECRET_KEY: ${{ secrets.S3_BENCH_LODESTAR_SECRET_KEY }}
S3_REGION: ${{ secrets.S3_BENCH_LODESTAR_REGION }}
S3_BUCKET: ${{ secrets.S3_BENCH_LODESTAR_BUCKET }}
S3_ENDPOINT: ${{ secrets.S3_BENCH_LODESTAR_ENDPOINT }}
# Key prefix to separate benchmark data from multiple repositories
S3_KEY_PREFIX: ${{ github.repository }}/${{ runner.os }}
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"test": "yarn run test:as-ci && yarn run test:unit",
"test:unit": "yarn run test:unit:node && yarn run test:unit:browser",
"test:unit:node": "mocha -r .babel-register test/*.spec.js",
"test:perf": "mocha -r .babel-register test/perf.test.js",
"benchmark": "node ./node_modules/.bin/benchmark 'test/benchmark.test.js'",
"benchmark:local": "yarn benchmark --local",
"test:unit:browser": "karma start --single-run --browsers ChromeHeadless,FirefoxHeadless karma.config.js",
"test:ci": "yarn test:as-ci",
"test:as": "asp --nortrace --verbose",
Expand Down Expand Up @@ -59,7 +60,8 @@
"karma-firefox-launcher": "^1.2.0",
"karma-mocha": "^1.3.0",
"karma-webpack": "^4.0.2",
"mocha": "^6.2.2",
"@dapplion/benchmark": "^0.1.6",
"mocha": "^8.3.0",
"webpack": "^4.39.3",
"webpack-cli": "^3.3.7"
}
Expand Down
20 changes: 20 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@

/**
* This is a hash representation with 8 numbers, each 4 bytes.
* That makes it 32 bytes, the same to Uint8Array(32).
*/
export interface HashObject {
h0: number;
h1: number;
h2: number;
h3: number;
h4: number;
h5: number;
h6: number;
h7: number;
}

export default class SHA256 {
constructor();
init(): this;
Expand All @@ -6,4 +22,8 @@ export default class SHA256 {

static digest(data: Uint8Array): Uint8Array;
static digest64(data: Uint8Array): Uint8Array;
static digestTwoHashObjects(obj1: HashObject, obj2: HashObject): HashObject;
}

export function hashObjectToByteArray(obj: HashObject, byteArr: ArrayLike<number>, offset: number): void;
export function byteArrayToHashObject(byteArr: ArrayLike<number>): HashObject;
Loading

0 comments on commit 07003a2

Please sign in to comment.