Skip to content

Commit

Permalink
fix: Add perfomance from perf_hooks (Node v8.5.0+) (#251)
Browse files Browse the repository at this point in the history
* fix: add import perfomance from  perf_hooks (Node v8.5.0+)

* only take perf measurements when we know we need them (#252)

Co-authored-by: Vladimir Berezovsky <[email protected]>
Co-authored-by: Rick Harris <[email protected]>
  • Loading branch information
3 people committed Apr 20, 2020
1 parent a937bf1 commit 6773642
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/endpoints/Endpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,19 @@ export default class Endpoint {
if (!request) {
throw new EndpointUndefinedError(mode);
}
const start = performance.now();

let start: number;
const { _analyticsCallback } = this.client;
if (performance && _analyticsCallback) {
start = performance.now();
}

const operation = request.call(this);
response = await operation;
const end = performance.now();
if (this.client._analyticsCallback) {
this.client._analyticsCallback({

if (start && performance && _analyticsCallback) {
const end = performance.now();
_analyticsCallback({
duration: end - start,
endpoint: this.name,
request: requestName,
Expand Down

0 comments on commit 6773642

Please sign in to comment.