New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TIMOB-26115] TiAPI: Add support for console.timeLog #10156
Conversation
Generated by 🚫 dangerJS |
iphone/Classes/TiConsole.m
Outdated
@@ -50,6 +50,27 @@ - (void)timeEnd:(id)label | |||
[_times removeObjectForKey:label]; | |||
} | |||
|
|||
- (void)timeLog:(id)args | |||
{ | |||
NSString *label = [args objectAtIndex:0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NSString *label = [args objectAtIndex:0] ?: @"default";
iphone/Classes/TiConsole.m
Outdated
[self logMessage:[logMessage componentsSeparatedByString:@" "] severity:@"warn"]; | ||
return; | ||
} | ||
double duration = [startTime timeIntervalSinceNow] * -1000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use NSTimeInterval
instead of double
. They are the same, but NSTimeInterval
is more known for storing time values.
iphone/Classes/TiConsole.m
Outdated
} | ||
double duration = [startTime timeIntervalSinceNow] * -1000; | ||
NSString *logMessage = [NSString stringWithFormat:@"%@: %0.fms ", label, duration]; | ||
if ([logData count]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use [logData count] > 0
for clearance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iOS approved
if (!startTime) { | ||
exports.warn(`Label "${label}" does not exist`); | ||
return; | ||
const warned = logTime(label); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the use of warned
here is a little confusing. What you're really determining is if the label existed.
…warn and inspect the string for console.timeLog. Have to skip on iOS due to native implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. The ti.shell/common JS bootstrap stuff that Josh Quick is doing could lead us to define this just once in JS code across all platforms and thereby allow the fancier unit tests I added to work on iOS too. But for now, this works.
JIRA: https://jira.appcelerator.org/browse/TIMOB-26115
Implement console.timeLog for Android and iOS
Test:
Should log something like the below, there's some slight discrepancies between how Arrays/Objects are logged on platforms.