Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1e9ff50

Browse files
theanarkhmarco-ippolito
authored andcommitted
lib: add toJSON to PerformanceMeasure
PR-URL:#53603Refs:#53570Reviewed-By: Chengzhong Wu <legendecas@gmail.com>Reviewed-By: Chemi Atlow <chemi@atlow.co.il>Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
1 parent460240c commit1e9ff50

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

‎lib/internal/perf/usertiming.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,16 @@ class PerformanceMeasure extends PerformanceEntry {
136136
validateInternalField(this,kDetail,'PerformanceMeasure');
137137
returnthis[kDetail];
138138
}
139+
140+
toJSON(){
141+
return{
142+
name:this.name,
143+
entryType:this.entryType,
144+
startTime:this.startTime,
145+
duration:this.duration,
146+
detail:this[kDetail],
147+
};
148+
}
139149
}
140150
ObjectDefineProperties(PerformanceMeasure.prototype,{
141151
detail:kEnumerableProperty,
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use strict';
2+
3+
constcommon=require('../common');
4+
constassert=require('assert');
5+
constutil=require('util');
6+
const{ performance, PerformanceObserver}=require('perf_hooks');
7+
8+
constperfObserver=newPerformanceObserver(common.mustCall((items)=>{
9+
constentries=items.getEntries();
10+
assert.ok(entries.length===1);
11+
for(constentryofentries){
12+
assert.ok(util.inspect(entry).includes('this is detail'));
13+
}
14+
}));
15+
16+
perfObserver.observe({entryTypes:['measure']});
17+
18+
performance.measure('sample',{
19+
detail:'this is detail',
20+
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp