My application slowed down a lot and I did some tests to find out why. I ran it twice, the first time I accessed an object that is in context, and the second access to a nonexistent object in JSContext
I tracked it to this part:
JSContext *ctx = [[JSContext alloc] init];
[ctx evaluateScript:scpt];
NSDate * start = [NSDate date];
for (int i=0; i<=100000; i++) {
ctx[@"someExisting"][@"view"][@"tint-color"];
}
NSDate * end = [NSDate date];
double timeTaken = [end timeIntervalSinceDate:start] * 1000;
NSLog(@"%g", timeTaken);
[ctx release];
I got 195.697
JSContext *ctx = [[JSContext alloc] init];
[ctx evaluateScript:scpt];
NSDate * start = [NSDate date];
for (int i=0; i<=100000; i++) {
ctx[@"nonExisting"][@"view"][@"tint-color"];
}
NSDate * end = [NSDate date];
double timeTaken = [end timeIntervalSinceDate:start] * 1000;
NSLog(@"%g", timeTaken);
[ctx release];
I got 8377.37! CPU and memory are also growing
Does anyone know if this is a mistake JavaScriptCoreor something that I am doing wrong?
source
share