Skip to content

Commit

Permalink
feat: clear & disable timing after ready (#4421)
Browse files Browse the repository at this point in the history
  • Loading branch information
atian25 committed Sep 8, 2020
1 parent d25d32e commit b31b47d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 30 deletions.
28 changes: 18 additions & 10 deletions .github/workflows/ci.yml → .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
name: Continuous integration
on: [push, pull_request]
on:
push:
branches: [ master ]
pull_request:
branches: [ master, 1.x ]
schedule:
- cron: '0 2 * * *'
jobs:
Runner:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest]
node-version: [8, 10, 12, 14]
os: [ ubuntu-latest, macOS-latest, windows-latest ]
node-version: [ 8, 10, 12, 14 ]
steps:
- name: Checkout Git Source
uses: actions/checkout@master

- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Install Dependencies
run: |
npm install
run: npm i -g npminstall && npminstall

- name: Continuous integration
run: npm run ci

- name: Code Coverage
run: |
npm install codecov -g
codecov
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
19 changes: 0 additions & 19 deletions appveyor.yml

This file was deleted.

2 changes: 2 additions & 0 deletions lib/egg.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,8 @@ class EggApplication extends EggCore {
const rundir = this.config.rundir;
const dumpFile = path.join(rundir, `${this.type}_timing_${process.pid}.json`);
fs.writeFileSync(dumpFile, CircularJSON.stringify(json, null, 2));
this.timing.clear();
this.timing.disable();
} catch (err) {
this.coreLogger.warn(`dumpTiming error: ${err.message}`);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"delegates": "^1.0.0",
"egg-cluster": "^1.23.0",
"egg-cookies": "^2.3.0",
"egg-core": "^4.16.1",
"egg-core": "^4.18.0",
"egg-development": "^2.4.2",
"egg-i18n": "^2.0.0",
"egg-jsonp": "^2.0.0",
Expand Down
9 changes: 9 additions & 0 deletions test/lib/egg.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,15 @@ describe('test/lib/egg.test.js', () => {
assert(json[0].pid === process.pid);
});

it('should disable & clear timing after ready', function* () {
const json = app.timing.toJSON();
assert(json.length === 0);
app.timing.start('a');
app.timing.end('a');
const json2 = app.timing.toJSON();
assert(json2.length === 0);
});

it('should ignore error when dumpTiming', done => {
mm(fs, 'writeFileSync', () => {
throw new Error('mock error');
Expand Down

0 comments on commit b31b47d

Please sign in to comment.