Skip to content

Commit

Permalink
add comment about optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
armcknight committed Apr 7, 2023
1 parent b596f4b commit 8a34588
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Sources/Sentry/include/SentryFormatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ sentry_stringForUInt64(uint64_t value)
static inline NSString *
sentry_formatHexAddress(NSNumber *value)
{
/*
* We observed a 41% speedup by using snprintf vs +[NSString stringWithFormat:]. In a trial
* using a profile, we observed the +[NSString stringWithFormat:] using 282ms of CPU time, vs
* 164ms of CPU time for snprintf. There is also an assumed space improvement due to not needing
* to allocate as many instances of NSString, like for the format string literal, instead only
* using stack-bound C strings.
*/
return sentry_snprintfHexAddress([value unsignedLongLongValue]);
}

Expand Down

0 comments on commit 8a34588

Please sign in to comment.