Skip to content

Commit

Permalink
rename Profiling -> Profiler
Browse files Browse the repository at this point in the history
  • Loading branch information
armcknight committed Jul 7, 2023
1 parent c88d79b commit 4c2017f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
12 changes: 6 additions & 6 deletions Sources/Sentry/Profiling/SentryProfilerState.mm
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
return [symbolNSStr substringWithRange:[match rangeAtIndex:1]];
}

@implementation SentryProfilingMutableState
@implementation SentryProfilerMutableState

- (instancetype)init
{
Expand All @@ -51,20 +51,20 @@ - (instancetype)init

@end

@implementation SentryProfilingState {
SentryProfilingMutableState *_mutableState;
@implementation SentryProfilerState {
SentryProfilerMutableState *_mutableState;
std::mutex _lock;
}

- (instancetype)init
{
if (self = [super init]) {
_mutableState = [[SentryProfilingMutableState alloc] init];
_mutableState = [[SentryProfilerMutableState alloc] init];
}
return self;
}

- (void)mutate:(void (^)(SentryProfilingMutableState *))block
- (void)mutate:(void (^)(SentryProfilerMutableState *))block
{
NSParameterAssert(block);
std::lock_guard<std::mutex> l(_lock);
Expand All @@ -73,7 +73,7 @@ - (void)mutate:(void (^)(SentryProfilingMutableState *))block

- (void)appendBacktrace:(const Backtrace &)backtrace
{
[self mutate:^(SentryProfilingMutableState *state) {
[self mutate:^(SentryProfilerMutableState *state) {
const auto threadID = sentry_stringForUInt64(backtrace.threadMetadata.threadID);

NSString *queueAddress = nil;
Expand Down
4 changes: 2 additions & 2 deletions Sources/Sentry/SentryProfiler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@
}

@implementation SentryProfiler {
SentryProfilingState *_state;
SentryProfilerState *_state;
std::shared_ptr<SamplingProfiler> _profiler;
SentryMetricProfiler *_metricProfiler;
SentryDebugImageProvider *_debugImageProvider;
Expand Down Expand Up @@ -469,7 +469,7 @@ - (void)start

SENTRY_LOG_DEBUG(@"Starting profiler.");

SentryProfilingState *const state = [[SentryProfilingState alloc] init];
SentryProfilerState *const state = [[SentryProfilerState alloc] init];
_state = state;
_profiler = std::make_shared<SamplingProfiler>(
[state](auto &backtrace) {
Expand Down
6 changes: 3 additions & 3 deletions Sources/Sentry/include/SentryProfilerState.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ NSString *parseBacktraceSymbolsFunctionName(const char *symbol);

@class SentrySample;

@interface SentryProfilingMutableState : NSObject
@interface SentryProfilerMutableState : NSObject
@property (nonatomic, strong, readonly) NSMutableArray<SentrySample *> *samples;
@property (nonatomic, strong, readonly) NSMutableArray<NSArray<NSNumber *> *> *stacks;
@property (nonatomic, strong, readonly) NSMutableArray<NSDictionary<NSString *, id> *> *frames;
Expand Down Expand Up @@ -70,9 +70,9 @@ NSString *parseBacktraceSymbolsFunctionName(const char *symbol);
NSMutableDictionary<NSString *, NSNumber *> *stackIndexLookup;
@end

@interface SentryProfilingState : NSObject
@interface SentryProfilerState : NSObject
// All functions are safe to call from multiple threads concurrently
- (void)mutate:(void (^)(SentryProfilingMutableState *))block;
- (void)mutate:(void (^)(SentryProfilerMutableState *))block;
- (void)appendBacktrace:(const sentry::profiling::Backtrace &)backtrace;
- (NSDictionary<NSString *, id> *)copyProfilingData;
@end
Expand Down
12 changes: 6 additions & 6 deletions Tests/SentryProfilerTests/SentryProfilerTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ - (void)testProfilerCanBeInitializedOffMainThread

- (void)testProfilerMutationDuringSlicing
{
SentryProfilingState *state = [[SentryProfilingState alloc] init];
SentryProfilerState *state = [[SentryProfilerState alloc] init];
// generate a large timeseries of simulated data

const auto threads = 5;
Expand Down Expand Up @@ -119,7 +119,7 @@ - (void)testProfilerMutationDuringSlicing
sliceExpectation.expectedFulfillmentCount = operations;

void (^sliceBlock)(void) = ^(void) {
[state mutate:^(SentryProfilingMutableState *mutableState) {
[state mutate:^(SentryProfilerMutableState *mutableState) {
__unused const auto slice = slicedProfileSamples(mutableState.samples, transaction);
[sliceExpectation fulfill];
}];
Expand Down Expand Up @@ -148,7 +148,7 @@ - (void)testProfilerMutationDuringSlicing

void (^mutateBlock)(void) = ^(void) {
[state mutate:^(
__unused SentryProfilingMutableState *mutableState) { [mutateExpectation fulfill]; }];
__unused SentryProfilerMutableState *mutableState) { [mutateExpectation fulfill]; }];
};

const auto sliceOperations = [[NSOperationQueue alloc] init]; // concurrent queue
Expand Down Expand Up @@ -177,7 +177,7 @@ - (void)testProfilerMutationDuringSlicing
*/
- (void)testProfilerMutationDuringSerialization
{
SentryProfilingState *state = [[SentryProfilingState alloc] init];
SentryProfilerState *state = [[SentryProfilerState alloc] init];
// initialize the data structures with some simulated data
{
ThreadMetadata threadMetadata;
Expand Down Expand Up @@ -289,7 +289,7 @@ - (void)testProfilerMutationDuringSerialization

- (void)testProfilerPayload
{
SentryProfilingState *state = [[SentryProfilingState alloc] init];
SentryProfilerState *state = [[SentryProfilerState alloc] init];

// record an initial backtrace

Expand Down Expand Up @@ -337,7 +337,7 @@ - (void)testProfilerPayload

[state appendBacktrace:backtrace2];

[state mutate:^(SentryProfilingMutableState *mutableState) {
[state mutate:^(SentryProfilerMutableState *mutableState) {
XCTAssertEqual(mutableState.frames.count, 5UL);
const auto expectedOrdered = @[
@"0x0000000000000123", @"0x0000000000000456", @"0x0000000000000789",
Expand Down

0 comments on commit 4c2017f

Please sign in to comment.