Oolite
Loading...
Searching...
No Matches
OOJSEngineTimeManagement.m
Go to the documentation of this file.
1/*
2
3OOJSEngineTimeManagement.h
4
5
6Copyright (C) 2010-2013 Jens Ayton
7
8Permission is hereby granted, free of charge, to any person obtaining a copy
9of this software and associated documentation files (the "Software"), to deal
10in the Software without restriction, including without limitation the rights
11to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12copies of the Software, and to permit persons to whom the Software is
13furnished to do so, subject to the following conditions:
14
15The above copyright notice and this permission notice shall be included in all
16copies or substantial portions of the Software.
17
18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24SOFTWARE.
25
26*/
27
29
30/* The SpiderMonkey version of this file implemented the time limiter
31 (with a watchdog thread that triggered SpiderMonkey's operation
32 callback) and the JavaScript profiler.
33
34 With QuickJS, the time limiter is implemented in OOJavaScriptEngine.m on
35 top of QuickJS's interrupt handler, which QuickJS polls while running
36 JavaScript, so neither the watchdog thread nor the operation callback is
37 needed.
38
39 The profiler is the SpiderMonkey one. JavaScript functions are profiled
40 through the function call hook added by Oolite's QuickJS-ng patch
41 (subprojects/packagefiles/quickjs-ng/0004-oolite-function-call-hook.patch),
42 which stands in for SpiderMonkey's MOZ_TRACE_JSCALLS function callback.
43 OOJS_QUICKJS_CALL_HOOK is set when building with the bundled, patched
44 QuickJS-ng; with a system QuickJS-ng, only natives are profiled.
45*/
46
47void OOJSTimeManagementInit(OOJavaScriptEngine* engine, JSRuntime* runtime)
48{
49 // The interrupt handler is installed by -[OOJavaScriptEngine init].
50}
51
52#if OOJS_PROFILE
53
54static BOOL sProfiling = NO;
55static BOOL sTracing = NO;
56static OOJSProfileStackFrame* sProfileStack = NULL;
57static NSMapTable* sProfileInfo;
58static double sProfilerOverhead;
59static double sProfilerTotalNativeTime;
60static double sProfilerEntryTimeLimit;
61static OOHighResTimeValue sProfilerStartTime;
62
63#if OOJS_QUICKJS_CALL_HOOK
64static double sProfilerTotalJavaScriptTime;
65
66/* Profile entries for JavaScript functions are keyed by the function's
67 bytecode. A reference to a function using each bytecode is held until
68 profiling ends, so the bytecode can't be freed and its address reused
69 for another function.
70*/
71static JSValue* sProfiledFunctions;
72static NSUInteger sProfiledFunctionCount;
73static NSUInteger sProfiledFunctionCapacity;
74
75static void FunctionCallHook(JSContext* context, JSValueConst function, const void* code, JSValueConst this, int argc, JSValueConst* argv, bool entering, void* opaque);
76#endif
77
78@interface OOTimeProfile (Private)
79
80- (void)setTotalTime:(double)value;
81- (void)setNativeTime:(double)value;
82- (void)setJavaScriptTime:(double)value;
83- (void)setProfilerOverhead:(double)value;
84- (void)setExtensionTime:(double)value;
85- (void)setProfileEntries:(NSArray*)value;
86
87- (NSDictionary*)propertyListRepresentation;
88
89@end
90
91@interface OOTimeProfileEntry (Private)
92
93- (id)initWithCName:(const char*)name;
94#if OOJS_QUICKJS_CALL_HOOK
95- (id)initWithJSFunction:(JSValueConst)function context:(JSContext*)context;
96#endif
97
98- (void)addSampleWithTotalTime:(OOTimeDelta)totalTime selfTime:(OOTimeDelta)selfTime;
99
100- (NSDictionary*)propertyListRepresentation;
101
102@end
103
104void OOJSBeginProfiling(BOOL trace)
105{
106 assert(sProfiling == NO);
107 sProfiling = YES;
108 sTracing = trace;
109 sProfileInfo = NSCreateMapTable(NSNonOwnedPointerMapKeyCallBacks, NSObjectMapValueCallBacks, 100);
110 sProfilerOverhead = 0.0;
111 sProfilerTotalNativeTime = 0.0;
112 sProfilerEntryTimeLimit = OOJSGetTimeLimiterLimit();
113
114#if OOJS_QUICKJS_CALL_HOOK
115 sProfilerTotalJavaScriptTime = 0.0;
116 sProfiledFunctionCount = 0;
117 JSContext* context = OOJSAcquireContext();
118 JS_SetFunctionCallHook(JS_GetRuntime(context), FunctionCallHook, NULL);
119 OOJSRelinquishContext(context);
120#endif
121
122 // This should be last for precision.
123 sProfilerStartTime = OOGetHighResTime();
124
125 if (trace) {
126 OOLog(@"script.javaScript.trace", @"%@", @">>>> Beginning trace.");
127 OOLogIndent();
128 }
129}
130
131OOTimeProfile* OOJSEndProfiling(void)
132{
133 // This should be at the top for precision.
135 // Time limiter should be as close to outermost as practical.
137
138 assert(sProfiling && sProfileStack == NULL);
139
140 sProfiling = NO;
141
142 OOTimeProfile* result = [[OOTimeProfile alloc] init];
143
144 [result setTotalTime:OOHighResTimeDeltaInSeconds(sProfilerStartTime, now)];
145 [result setNativeTime:sProfilerTotalNativeTime];
146#if OOJS_QUICKJS_CALL_HOOK
147 [result setJavaScriptTime:sProfilerTotalJavaScriptTime];
148#else
149 [result setJavaScriptTime:[result totalTime] - sProfilerTotalNativeTime];
150#endif
151 [result setProfilerOverhead:sProfilerOverhead];
152
153 double currentTimeLimit = OOJSGetTimeLimiterLimit();
154 [result setExtensionTime:currentTimeLimit - sProfilerEntryTimeLimit];
155
156 [result setProfileEntries:[NSAllMapTableValues(sProfileInfo) sortedArrayUsingSelector:@selector(compareBySelfTimeReverse:)]];
157
158 if (sTracing) {
159 OOLogOutdent();
160 OOLog(@"script.javaScript.trace", @"%@", @"<<<< End of trace.");
161 sTracing = NO;
162 }
163
164 // Clean up.
165#if OOJS_QUICKJS_CALL_HOOK
166 JSContext* context = OOJSAcquireContext();
167 JS_SetFunctionCallHook(JS_GetRuntime(context), NULL, NULL);
168 for (NSUInteger i = 0; i < sProfiledFunctionCount; i++) {
169 JS_FreeValue(context, sProfiledFunctions[i]);
170 }
171 sProfiledFunctionCount = 0;
172 OOJSRelinquishContext(context);
173#endif
174
175 NSFreeMapTable(sProfileInfo);
176 OODisposeHighResTime(sProfilerStartTime);
177
179
181 return [result autorelease];
182}
183
184BOOL OOJSIsProfiling(void)
185{
186 return sProfiling;
187}
188
189static void UpdateProfileForFrame(OOHighResTimeValue now, OOJSProfileStackFrame* frame);
190
191#if OOJS_QUICKJS_CALL_HOOK
192static void CleanUpJSFrame(OOJSProfileStackFrame* frame)
193{
194 OODisposeHighResTime(frame->startTime);
195 free(frame);
196}
197
198static void HoldProfiledFunction(JSContext* context, JSValueConst function)
199{
200 if (sProfiledFunctionCount == sProfiledFunctionCapacity) {
201 sProfiledFunctionCapacity = sProfiledFunctionCapacity ? sProfiledFunctionCapacity * 2 : 64;
202 sProfiledFunctions = realloc(sProfiledFunctions, sProfiledFunctionCapacity * sizeof *sProfiledFunctions);
203 assert(sProfiledFunctions != NULL);
204 }
205 sProfiledFunctions[sProfiledFunctionCount++] = JS_DupValue(context, function);
206}
207
208static void TraceEnterJSFunction(JSContext* context, JSValueConst this, int argc, JSValueConst* argv, OOTimeProfileEntry* profileEntry)
209{
210 NSMutableString* name = [NSMutableString stringWithFormat:@"%@(", [profileEntry function]];
211
212 // Temporarily disable profiling as we'll call out to profiled functions to get value descriptions.
213 sProfiling = NO;
214
215 BOOL first = YES;
216 if (!JS_IsUndefined(this)) {
217 [name appendFormat:@"this: %@", OOJSDescribeValue(context, this, YES)];
218 first = NO;
219 }
220 for (int i = 0; i < argc; i++) {
221 if (!first)
222 [name appendString:@", "];
223 else
224 first = NO;
225 [name appendString:OOJSDescribeValue(context, argv[i], YES)];
226 }
227
228 sProfiling = YES;
229
230 [name appendString:@")"];
231 OOLog(@"script.javaScript.trace.JS", @">> %@ [JS]", name);
232 OOLogIndent();
233}
234
235static void FunctionCallHook(JSContext* context, JSValueConst function, const void* code, JSValueConst this, int argc, JSValueConst* argv, bool entering, void* opaque)
236{
237 if (EXPECT(!sProfiling))
238 return;
239
241 BOOL startOwnedByFrame = NO;
242
243 NSAutoreleasePool* pool = [NSAutoreleasePool new];
244
245 if (entering) {
246 // Create profile entry up front so we can shove the JS function in it.
247 OOTimeProfileEntry* entry = NSMapGet(sProfileInfo, code);
248 if (entry == nil) {
249 entry = [[OOTimeProfileEntry alloc] initWithJSFunction:function context:context];
250 NSMapInsertKnownAbsent(sProfileInfo, code, entry);
251 [entry release];
252 HoldProfiledFunction(context, function);
253 }
254
255 if (EXPECT_NOT(sTracing)) {
256 // We use EXPECT_NOT here because profiles are time-critical and traces are not.
257 TraceEnterJSFunction(context, this, argc, argv, entry);
258 }
259
260 // Make a stack frame on the heap.
261 OOJSProfileStackFrame* frame = malloc(sizeof(OOJSProfileStackFrame));
262 assert(frame != NULL);
263
264 *frame = (OOJSProfileStackFrame) {
265 .back = sProfileStack,
266 .key = code,
267 .startTime = start,
268 .subTime = 0.0,
269 .total = &sProfilerTotalJavaScriptTime,
270 .cleanup = CleanUpJSFrame
271 };
272
273 sProfileStack = frame;
274 startOwnedByFrame = YES;
275 } else if (sProfileStack != NULL && sProfileStack->cleanup == CleanUpJSFrame && sProfileStack->key == code) {
276 // Exiting. A frame entered before profiling started is not on the profile stack.
277 UpdateProfileForFrame(start, sProfileStack);
278 }
279
280 [pool release];
281
283 double currentOverhead = OOHighResTimeDeltaInSeconds(start, end);
284 sProfilerOverhead += currentOverhead;
285 OOJSExcludeTimeFromLimiter(currentOverhead);
286 if (!startOwnedByFrame)
289}
290#endif
291
292void OOJSProfileEnter(OOJSProfileStackFrame* frame, const char* function)
293{
294 if (EXPECT(!sProfiling))
295 return;
296 if (EXPECT_NOT(sTracing)) {
297 // We use EXPECT_NOT here because profiles are time-critical and traces are not.
298 OOLog(@"script.javaScript.trace.ON", @">> %s [ON]", function);
299 OOLogIndent();
300 }
301
302 *frame = (OOJSProfileStackFrame) {
303 .back = sProfileStack,
304 .key = function,
305 .function = function,
306 .startTime = OOGetHighResTime(),
307 .total = &sProfilerTotalNativeTime
308 };
309 sProfileStack = frame;
310}
311
312void OOJSProfileExit(OOJSProfileStackFrame* frame)
313{
314 if (EXPECT(!sProfiling))
315 return;
316
317 /* A frame entered before profiling started (such as the console's
318 profile() itself) is not on the profile stack.
319 */
320 OOJSProfileStackFrame* search = sProfileStack;
321 while (search != NULL && search != frame)
322 search = search->back;
323 if (search == NULL)
324 return;
325
327 NSAutoreleasePool* pool = [NSAutoreleasePool new];
328 BOOL done = NO;
329
330 // Pop any frames above this one, as for a native that threw.
331 for (;;) {
332 assert(sProfileStack != NULL);
333
334 done = (sProfileStack == frame);
335 UpdateProfileForFrame(now, sProfileStack);
336 if (EXPECT(done))
337 break;
338 }
339
340 [pool release];
341
342 OODisposeHighResTime(frame->startTime);
343
345 double currentOverhead = OOHighResTimeDeltaInSeconds(now, end);
346 sProfilerOverhead += currentOverhead;
347 OOJSExcludeTimeFromLimiter(currentOverhead);
348
351}
352
353static void UpdateProfileForFrame(OOHighResTimeValue now, OOJSProfileStackFrame* frame)
354{
355 sProfileStack = frame->back;
356
357 OOTimeProfileEntry* entry = NSMapGet(sProfileInfo, frame->key);
358 if (entry == nil) {
359 entry = [[OOTimeProfileEntry alloc] initWithCName:frame->function];
360 NSMapInsertKnownAbsent(sProfileInfo, frame->key, entry);
361 [entry release];
362 }
363
364 OOTimeDelta time = OOHighResTimeDeltaInSeconds(frame->startTime, now);
365 OOTimeDelta selfTime = time - frame->subTime;
366 [entry addSampleWithTotalTime:time selfTime:selfTime];
367
368 *(frame->total) += selfTime;
369 if (sProfileStack != NULL)
370 sProfileStack->subTime += time;
371
372 if (frame->cleanup != NULL)
373 frame->cleanup(frame);
374
375 if (EXPECT_NOT(sTracing))
376 OOLogOutdent();
377}
378
379@implementation OOTimeProfile
380
381- (void)dealloc
382{
383 DESTROY(_profileEntries);
384
385 [super dealloc];
386}
387
388- (NSString*)description
389{
390 double totalTime = [self totalTime];
391
392 NSMutableString* result = [NSMutableString stringWithFormat:
393 @"Total time: %g ms\n"
394 "JavaScript: %g ms, native: %g ms\n"
395 "Counted towards limit: %g ms, excluded: %g ms\n"
396 "Profiler overhead: %g ms",
397 totalTime * 1000.0,
398 [self javaScriptTime] * 1000.0, [self nativeTime] * 1000.0,
399 [self nonExtensionTime] * 1000.0, [self extensionTime] * 1000.0,
400 [self profilerOverhead] * 1000.0];
401
402 NSArray* profileEntries = [self profileEntries];
403 NSUInteger i, count = [profileEntries count];
404 if (count != 0) {
405 [result appendString:@"\n NAME T COUNT TOTAL SELF TOTAL% SELF% SELFMAX"];
406 for (i = 0; i < count; i++) {
407 OOTimeProfileEntry* entry = [profileEntries objectAtIndex:i];
408
409 double totalPc = [entry totalTimeSum] * 100.0 / totalTime;
410 double selfPc = [entry selfTimeSum] * 100.0 / totalTime;
411
412 [result appendFormat:@"\n%60s %c%7lu %8.2f %8.2f %5.1f %5.1f %8.2f",
413 [[entry function] UTF8String],
414 [entry isJavaScriptFrame] ? 'J' : 'N',
415 (unsigned long)[entry hitCount], [entry totalTimeSum] * 1000.0, [entry selfTimeSum] * 1000.0, totalPc, selfPc, [entry selfTimeMax] * 1000.0];
416 }
417 }
418
419 return result;
420}
421
422- (double)totalTime
423{
424 return _totalTime;
425}
426
427- (void)setTotalTime:(double)value
428{
429 _totalTime = value;
430}
431
432- (double)javaScriptTime
433{
434 return _javaScriptTime;
435}
436
437- (void)setJavaScriptTime:(double)value
438{
439 _javaScriptTime = value;
440}
441
442- (double)nativeTime
443{
444 return _nativeTime;
445}
446
447- (void)setNativeTime:(double)value
448{
449 _nativeTime = value;
450}
451
452- (double)extensionTime
453{
454 return _extensionTime;
455}
456
457- (void)setExtensionTime:(double)value
458{
459 _extensionTime = value;
460}
461
462- (double)nonExtensionTime
463{
464 return _totalTime - _extensionTime;
465}
466
467- (double)profilerOverhead
468{
469 return _profilerOverhead;
470}
471
472- (void)setProfilerOverhead:(double)value
473{
474 _profilerOverhead = value;
475}
476
477- (NSArray*)profileEntries
478{
479 return _profileEntries;
480}
481
482- (void)setProfileEntries:(NSArray*)value
483{
484 if (_profileEntries != value) {
485 [_profileEntries release];
486 _profileEntries = [value retain];
487 }
488}
489
490- (JSValue)oo_jsValueInContext:(JSContext*)context
491{
492 return OOJSValueFromNativeObject(context, [self propertyListRepresentation]);
493}
494
495- (NSDictionary*)propertyListRepresentation
496{
497 NSArray* profileEntries = [self profileEntries];
498 NSMutableArray* convertedEntries = [NSMutableArray arrayWithCapacity:[profileEntries count]];
499 OOTimeProfileEntry* entry = nil;
500 foreach (entry, profileEntries) {
501 [convertedEntries addObject:[entry propertyListRepresentation]];
502 }
503
504 return [NSDictionary dictionaryWithObjectsAndKeys:
505 convertedEntries, @"profiles",
506 [NSNumber numberWithDouble:[self totalTime]], @"totalTime",
507 [NSNumber numberWithDouble:[self javaScriptTime]], @"javaScriptTime",
508 [NSNumber numberWithDouble:[self nativeTime]], @"nativeTime",
509 [NSNumber numberWithDouble:[self extensionTime]], @"extensionTime",
510 [NSNumber numberWithDouble:[self nonExtensionTime]], @"nonExtensionTime",
511 [NSNumber numberWithDouble:[self profilerOverhead]], @"profilerOverhead",
512 nil];
513}
514
515@end
516
517@implementation OOTimeProfileEntry
518
519- (id)initWithCName:(const char*)name
520{
521 NSAssert(sProfiling, @"Can't create profile entries while not profiling.");
522
523 if ((self = [super init])) {
524 if (name != NULL) {
525 _function = [[NSString stringWithUTF8String:name] retain];
526 }
527 }
528
529 return self;
530}
531
532#if OOJS_QUICKJS_CALL_HOOK
533- (id)initWithJSFunction:(JSValueConst)function context:(JSContext*)context
534{
535 if ((self = [self initWithCName:NULL])) {
536 // Temporarily disable profiling so we don't profile the profiler while it's profiling the profilee.
537 sProfiling = NO;
538 _isJavaScriptFrame = YES;
539
540 JSAtom nameAtom, fileAtom;
541 int line;
542 NSString* funcName = nil;
543 NSString* location = nil;
544 if (JS_GetFunctionInfo(context, function, &nameAtom, &fileAtom, &line)) {
545 if (nameAtom != JS_ATOM_NULL) {
546 funcName = OOStringFromJSID(nameAtom);
547 JS_FreeAtom(context, nameAtom);
548 }
549 if (fileAtom != JS_ATOM_NULL) {
550 location = [NSString stringWithFormat:@"%@:%i", OOStringFromJSID(fileAtom), line];
551 JS_FreeAtom(context, fileAtom);
552 }
553 }
554 if ([funcName length] == 0)
555 funcName = @"<anonymous>";
556
557 if (location != nil) {
558 _function = [[NSString alloc] initWithFormat:@"(%@) %@", location, funcName];
559 } else
560 _function = [funcName retain];
561
562 sProfiling = YES;
563 }
564
565 return self;
566}
567#endif
568
569- (void)dealloc
570{
571 DESTROY(_function);
572
573 [super dealloc];
574}
575
576- (void)addSampleWithTotalTime:(OOTimeDelta)totalTime selfTime:(OOTimeDelta)selfTime
577{
578 _hitCount++;
579 _totalTimeSum += totalTime;
580 _selfTimeSum += selfTime;
581 _totalTimeMax = fmax(_totalTimeMax, totalTime);
582 _selfTimeMax = fmax(_selfTimeMax, selfTime);
583}
584
585- (NSString*)description
586{
587 if (_hitCount == 0)
588 return [NSString stringWithFormat:@"%@: --", _function];
589
590 // Convert everything to milliseconds.
591 float totalTimeSum = _totalTimeSum * 1000.0;
592 float selfTimeSum = _selfTimeSum * 1000.0;
593 float totalTimeMax = _totalTimeMax * 1000.0;
594 float selfTimeMax = _selfTimeMax * 1000.0;
595
596 if (totalTimeSum == selfTimeSum && totalTimeMax == selfTimeMax) {
597 if (_hitCount == 1) {
598 return [NSString stringWithFormat:@"%@: 1 time, %g ms", _function, totalTimeSum];
599 } else {
600 return [NSString stringWithFormat:@"%@: %lu times, total %g ms, avg %g ms, max %g ms", _function, _hitCount, totalTimeSum, totalTimeSum / _hitCount, totalTimeMax];
601 }
602 } else {
603 if (_hitCount == 1) {
604 return [NSString stringWithFormat:@"%@: 1 time, %g ms (self %g ms)", _function, totalTimeSum, selfTimeSum];
605 } else {
606 return [NSString stringWithFormat:@"%@: %lu times, total %g ms (self %g ms), avg %g ms (self %g ms), max %g ms, max self %g ms", _function, _hitCount, totalTimeSum, selfTimeSum, totalTimeSum / _hitCount, selfTimeSum / _hitCount, totalTimeMax, selfTimeMax];
607 }
608 }
609}
610
611- (NSString*)function
612{
613 return _function;
614}
615
616- (NSUInteger)hitCount
617{
618 return _hitCount;
619}
620
621- (double)totalTimeSum
622{
623 return _totalTimeSum;
624}
625
626- (double)selfTimeSum
627{
628 return _selfTimeSum;
629}
630
631- (double)totalTimeAverage
632{
633 return _hitCount ? (_totalTimeSum / _hitCount) : 0.0;
634}
635
636- (double)selfTimeAverage
637{
638 return _hitCount ? (_selfTimeSum / _hitCount) : 0.0;
639}
640
641- (double)totalTimeMax
642{
643 return _totalTimeMax;
644}
645
646- (double)selfTimeMax
647{
648 return _selfTimeMax;
649}
650
651- (BOOL)isJavaScriptFrame
652{
653 return _isJavaScriptFrame;
654}
655
656- (NSComparisonResult)compareByTotalTime:(OOTimeProfileEntry*)other
657{
658 return -[self compareByTotalTimeReverse:other];
659}
660
661- (NSComparisonResult)compareByTotalTimeReverse:(OOTimeProfileEntry*)other
662{
663 double selfTotal = [self totalTimeSum];
664 double otherTotal = [other totalTimeSum];
665
666 if (selfTotal < otherTotal)
667 return NSOrderedDescending;
668 if (selfTotal > otherTotal)
669 return NSOrderedAscending;
670 return NSOrderedSame;
671}
672
673- (NSComparisonResult)compareBySelfTime:(OOTimeProfileEntry*)other
674{
675 return -[self compareBySelfTimeReverse:other];
676}
677
678- (NSComparisonResult)compareBySelfTimeReverse:(OOTimeProfileEntry*)other
679{
680 double selfTotal = [self selfTimeSum];
681 double otherTotal = [other selfTimeSum];
682
683 if (selfTotal < otherTotal)
684 return NSOrderedDescending;
685 if (selfTotal > otherTotal)
686 return NSOrderedAscending;
687 return NSOrderedSame;
688}
689
690- (JSValue)oo_jsValueInContext:(JSContext*)context
691{
692 return OOJSValueFromNativeObject(context, [self propertyListRepresentation]);
693}
694
695- (NSDictionary*)propertyListRepresentation
696{
697 return [NSDictionary dictionaryWithObjectsAndKeys:
698 _function, @"name",
699 [NSNumber numberWithUnsignedInteger:[self hitCount]], @"hitCount",
700 [NSNumber numberWithDouble:[self totalTimeSum]], @"totalTimeSum",
701 [NSNumber numberWithDouble:[self selfTimeSum]], @"selfTimeSum",
702 [NSNumber numberWithDouble:[self totalTimeAverage]], @"totalTimeAverage",
703 [NSNumber numberWithDouble:[self selfTimeAverage]], @"selfTimeAverage",
704 [NSNumber numberWithDouble:[self totalTimeMax]], @"totalTimeMax",
705 [NSNumber numberWithDouble:[self selfTimeMax]], @"selfTimeMax",
706 [NSNumber numberWithBool:[self isJavaScriptFrame]], @"isJavaScriptFrame",
707 nil];
708}
709
710@end
711
712#endif
#define DESTROY(x)
#define EXPECT_NOT(x)
#define EXPECT(x)
#define OOJSProfileExit(frame)
#define OOJSProfileEnter(frame, function)
OOTimeDelta OOJSGetTimeLimiterLimit(void)
void OOJSPauseTimeLimiter(void)
NSString * OOStringFromJSID(jsid propID)
OOINLINE jsval OOJSValueFromNativeObject(JSContext *context, id object)
OOINLINE JSContext * OOJSAcquireContext(void)
OOINLINE void OOJSRelinquishContext(JSContext *context)
void OOJSResumeTimeLimiter(void)
void OOLogOutdent(void)
Definition OOLogging.m:354
#define OOLog(class, format,...)
Definition OOLogging.h:84
void OOLogIndent(void)
Definition OOLogging.m:345
return self
unsigned count
return nil
OOTimeDelta OOHighResTimeDeltaInSeconds(OOHighResTimeValue startTime, OOHighResTimeValue endTime)
uint64_t OOHighResTimeValue
#define OOGetHighResTime
#define OODisposeHighResTime(time)
double OOTimeDelta
Definition OOTypes.h:193
void OOJSTimeManagementInit(OOJavaScriptEngine *engine, JSRuntime *runtime)