-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bbfcdf2
commit 1012a49
Showing
5 changed files
with
60 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { expect } from 'chai'; | ||
import { AsyncInterceptor, AsyncResourceMap, stackTrace } from '../async-interceptor'; | ||
import Benchmarkify from "benchmarkify"; | ||
|
||
const benchmark = new Benchmarkify("Meteor Perf", { chartImage: true }).printHeader(); | ||
|
||
benchmark.createSuite("Stack Trace", { time: 1000 }) | ||
.add("default error stack trace", () => { | ||
return new Error().stack; | ||
}) | ||
.ref("clean stack trace", () => { | ||
return (new Error()).stack.split('\n').slice(2).filter(line => { | ||
return !['AsyncHook.init', 'node:internal/async_hooks'].some(fn => line.includes(fn)); | ||
}).join('\n'); | ||
}); | ||
|
||
|
||
await benchmark.run(); | ||
|
||
describe('Async Interceptor', () => { | ||
it('get stack trace', async () => { | ||
const stack = stackTrace(); | ||
|
||
expect(stack).to.be.a('string'); | ||
}); | ||
|
||
it('should capture async operations', async () => { | ||
AsyncInterceptor.enable(); | ||
|
||
await new Promise((resolve) => { | ||
setTimeout(resolve, 100); | ||
}); | ||
|
||
AsyncInterceptor.disable(); | ||
|
||
expect(AsyncResourceMap.size).to.be.greaterThan(0); | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
import './observer.test'; | ||
import './observer.test'; | ||
import './async-interceptor.test'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters