[cost] Add tests for objc differential cost analysis

Reviewed By: jvillard

Differential Revision: D26314704

fbshipit-source-id: e2133dd03
master
Ezgi Çiçek 4 years ago committed by Facebook GitHub Bot
parent b50ff19291
commit 17a3bec2ca

@ -1 +1 @@
{"top":{"current":0,"previous":0},"unreachable":{"current":0,"previous":0},"zero":{"current":0,"previous":0},"degrees":[{"degree":0,"current":20,"previous":15},{"degree":100,"current":4,"previous":1}]} {"top":{"current":0,"previous":0},"unreachable":{"current":0,"previous":0},"zero":{"current":0,"previous":0},"degrees":[{"degree":0,"current":20,"previous":15},{"degree":100,"current":5,"previous":1},{"degree":200,"current":1,"previous":0}]}

@ -0,0 +1,2 @@
EXECUTION_TIME_COMPLEXITY_INCREASE, no_bucket, src/DiffBlock.m, Handler.func_linear:, 0, [Previous Cost of func_linear: is 4 + 5 ⋅ (array->elements.length + 1) (degree is 1),{array->elements.length + 1},Loop,Updated Cost of func_linear: is 4 + 3 ⋅ array->elements.length × (array->elements.length + 1) + 8 ⋅ (array->elements.length + 1) + 3 ⋅ (array->elements.length + 1) × (array->elements.length + 1) (degree is 2),{array->elements.length + 1},Loop,{array->elements.length},Call to Handler.loop_linear:,Loop]
EXECUTION_TIME_COMPLEXITY_INCREASE, no_bucket, src/DiffBlock.m, objc_blockHandler.func_linear_1, 0, [Previous Cost of objc_blockHandler.func_linear_1 is 21 (degree is 0),Updated Cost of objc_blockHandler.func_linear_1 is 23 + 3 ⋅ str.length + 3 ⋅ (str.length + 1) (degree is 1),{str.length},Loop]

@ -37,11 +37,20 @@
- (void (^)(NSString*))func_linear { - (void (^)(NSString*))func_linear {
return ^(NSString* str) { return ^(NSString* str) {
NSLog(@"Report error : %@ \n", str); NSLog(@"Report error : %@ \n", str);
for (int i = 0; i < str.length; i++) {
} // we get a complexity increase here for the block, but we should print it
// better
}; };
} }
+ (void)loop_linear:(NSArray*)array {
for (int i = 0; i < array.count; i++) {
}
}
- (void)func_linear:(NSArray*)array { - (void)func_linear:(NSArray*)array {
for (id value in array) { for (id value in array) {
[Handler loop_linear:array];
} }
} }

Loading…
Cancel
Save