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

Dev #6

Merged
merged 15 commits into from
Feb 12, 2024
17 changes: 8 additions & 9 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
name: NodeJS CI Codecov
name: NodeJS c8 coverage on CI to Codecov
on: [push, pull_request]
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v4
- name: Setup NodeJS
uses: actions/setup-node@master
uses: actions/setup-node@v4
with:
node-version: '14.16.0'
- name: Install dependencies
run: yarn
- name: Generate coverage
run: yarn c8-text-lcov
node-version: latest
run: npm i -G c8
run: npm run ci
- name: Upload to Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
files: ./coverage.lcov
name: codecov-umbrella
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,5 @@ typings/

# next.js build output
.next

*.lcov
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 Tom
Copyright (c) 2018 Tom Shaver

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,26 @@

An oversimplified Mocha-inspired test tool.

Developed on Ubuntu 18+ through [UserLAnd on Android](https://play.google.com/store/apps/details?id=tech.ula).
Initially developed on Ubuntu Linux through [UserLAnd](https://github.com/CypherpunkArmory/UserLAnd) on [Android](https://play.google.com/store/apps/details?id=tech.ula).


[![Codacy Badge](https://app.codacy.com/project/badge/Grade/75eeb5d0ccfb41a8916ed8ebaee38acb)](https://www.codacy.com/gh/l3laze/testease/dashboard?utm_source=github.com&utm_medium=referral&utm_content=l3laze/testease&utm_campaign=Badge_Grade) [![codecov](https://codecov.io/gh/l3laze/testease/branch/master/graph/badge.svg)](https://codecov.io/gh/l3laze/testease)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/75eeb5d0ccfb41a8916ed8ebaee38acb)](https://app.codacy.com/gh/l3laze/testease/dashboard) [![codecov](https://codecov.io/gh/l3laze/testease/branch/master/graph/badge.svg)](https://codecov.io/gh/l3laze/testease)


![Lines of Code](https://tokei.rs/b1/github/l3laze/testease) [![Generic badge](https://img.shields.io/badge/Made%20with-NodeJS-black.svg)](https://shields.io/)
![Lines of code](https://img.shields.io/tokei/lines/github/l3laze/testease) ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/l3laze/testease) ![Generic Custom Badge](https://img.shields.io/badge/Made_with_NodeJS-and_%3C3-red)


----


<details><summary><b>Table of contents</b></summary>

* [Demo](#Demo)
* [Installation](#Installation)
* [Usage](#Usage)
- [Options](#Options)
- [Example](#Example)
- [Output](#Output)
* [Demo](#Demo)
</details>


Expand Down
56 changes: 56 additions & 0 deletions bench.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
'use strict'

function bench () {
const results = []
let timeTaken = 0
let runnerStarted = 0
let runnerTook = 0

function formatResults () {
return results
}

async function benchmark (f, timeLimit) {
const runner = async function () {
const start = Date.now()
await f()
results.push(Date.now() - start)
}

const benchStart = Date.now()

do {
runnerStarted = Date.now()
await runner()
runnerTook = Date.now() - runnerStarted

timeTaken += runnerTook

if (timeTaken >= (timeLimit -
Math.ceil(results.reduce((accumulator, current) => accumulator + current, 0) / results.length))) {
break
}
} while (true)

return {
results: formatResults(),
min: Math.min(...results),
max: Math.max(...results),
average: Math.ceil(results.reduce((accumulator, current) => accumulator + current, 0) / results.length),
runs: results.length,
timeLimit,
timeTaken,
benchTime: Date.now() - benchStart
}
}

return {
benchmark
}
}

const benchmark = bench().benchmark

export {
benchmark
}
Loading