Skip to content

Commit

Permalink
perf: speculative performance improvemnt, testing HasListeners before…
Browse files Browse the repository at this point in the history
… use
  • Loading branch information
kieronlanning committed May 20, 2024
1 parent 3984f1b commit 7d23021
Show file tree
Hide file tree
Showing 38 changed files with 483 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SOLUTION_FILE = $(ROOT_FOLDER)Purview.Telemetry.SourceGenerator.sln
TEST_PROJECT = $(ROOT_FOLDER)Purview.Telemetry.SourceGenerator.sln
CONFIGURATION = Release

PACK_VERSION = 1.0.6
PACK_VERSION = 1.0.7
ARTIFACT_FOLDER = p:/sync-projects/.local-nuget/

# Targets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ static void RecordExceptionInternal(System.Diagnostics.Activity? activity, Syste
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public void Activity(string stringParam, int intParam, bool boolParam)
{
if (!_activitySource.HasListeners())
{
return;
}

System.Diagnostics.Activity? activityActivity = _activitySource.StartActivity(name: "Activity", kind: System.Diagnostics.ActivityKind.Internal, parentId: default, tags: default, links: default, startTime: default);

if (activityActivity != null)
Expand All @@ -58,6 +63,11 @@ public void Activity(string stringParam, int intParam, bool boolParam)
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public void Event(string stringParam, int intParam, bool boolParam)
{
if (!_activitySource.HasListeners())
{
return;
}

if (System.Diagnostics.Activity.Current != null)
{
System.Diagnostics.ActivityTagsCollection tagsCollectionEvent = new System.Diagnostics.ActivityTagsCollection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,22 @@ static void RecordExceptionInternal(System.Diagnostics.Activity? activity, Syste
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public void Activity()
{
if (!_activitySource.HasListeners())
{
return;
}

System.Diagnostics.Activity? activityActivity = _activitySource.StartActivity(name: "Activity", kind: System.Diagnostics.ActivityKind.Internal, parentId: default, tags: default, links: default, startTime: default);
}

[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public void Context(System.Diagnostics.Activity activityParameter, string? stringParam, int? intParam, bool? boolParam)
{
if (!_activitySource.HasListeners())
{
return;
}

if (activityParameter != null)
{
activityParameter.SetTag("intparam", intParam);
Expand All @@ -58,6 +68,11 @@ public void Context(System.Diagnostics.Activity activityParameter, string? strin
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public void ContextWithNullableParams(System.Diagnostics.Activity? activityParameter, string? stringParam, int? intParam, bool? boolParam)
{
if (!_activitySource.HasListeners())
{
return;
}

if (activityParameter != null)
{
activityParameter.SetTag("intparam", intParam);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,22 @@ static void RecordExceptionInternal(System.Diagnostics.Activity? activity, Syste
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public void Activity()
{
if (!_activitySource.HasListeners())
{
return;
}

System.Diagnostics.Activity? activityActivity = _activitySource.StartActivity(name: "Activity", kind: System.Diagnostics.ActivityKind.Internal, parentId: default, tags: default, links: default, startTime: default);
}

[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public System.Diagnostics.Activity Context(System.Diagnostics.Activity activityParameter, string? stringParam, int? intParam, bool? boolParam)
{
if (!_activitySource.HasListeners())
{
return null!;
}

if (activityParameter != null)
{
activityParameter.SetTag("intparam", intParam);
Expand All @@ -60,6 +70,11 @@ public System.Diagnostics.Activity Context(System.Diagnostics.Activity activityP
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public System.Diagnostics.Activity? ContextWithNullableParams(System.Diagnostics.Activity? activityParameter, string? stringParam, int? intParam, bool? boolParam)
{
if (!_activitySource.HasListeners())
{
return null;
}

if (activityParameter != null)
{
activityParameter.SetTag("intparam", intParam);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,22 @@ static void RecordExceptionInternal(System.Diagnostics.Activity? activity, Syste
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public void Activity()
{
if (!_activitySource.HasListeners())
{
return;
}

System.Diagnostics.Activity? activityActivity = _activitySource.StartActivity(name: "Activity", kind: System.Diagnostics.ActivityKind.Internal, parentId: default, tags: default, links: default, startTime: default);
}

[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public System.Diagnostics.Activity Context(string? stringParam, int? intParam, bool? boolParam)
{
if (!_activitySource.HasListeners())
{
return null!;
}

if (System.Diagnostics.Activity.Current != null)
{
System.Diagnostics.Activity.Current.SetTag("intparam", intParam);
Expand All @@ -60,6 +70,11 @@ public System.Diagnostics.Activity Context(string? stringParam, int? intParam, b
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public System.Diagnostics.Activity? ContextWithNullableParams(string? stringParam, int? intParam, bool? boolParam)
{
if (!_activitySource.HasListeners())
{
return null;
}

if (System.Diagnostics.Activity.Current != null)
{
System.Diagnostics.Activity.Current.SetTag("intparam", intParam);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,22 @@ static void RecordExceptionInternal(System.Diagnostics.Activity? activity, Syste
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public void Activity()
{
if (!_activitySource.HasListeners())
{
return;
}

System.Diagnostics.Activity? activityActivity = _activitySource.StartActivity(name: "Activity", kind: System.Diagnostics.ActivityKind.Internal, parentId: default, tags: default, links: default, startTime: default);
}

[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public System.Diagnostics.Activity Context(string stringParam, int intParam, bool boolParam)
{
if (!_activitySource.HasListeners())
{
return null!;
}

if (System.Diagnostics.Activity.Current != null)
{
System.Diagnostics.Activity.Current.SetTag("intparam", intParam);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,22 @@ static void RecordExceptionInternal(System.Diagnostics.Activity? activity, Syste
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public void Activity()
{
if (!_activitySource.HasListeners())
{
return;
}

System.Diagnostics.Activity? activityActivity = _activitySource.StartActivity(name: "Activity", kind: System.Diagnostics.ActivityKind.Internal, parentId: default, tags: default, links: default, startTime: default);
}

[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public System.Diagnostics.Activity Context(string stringParam, int intParam, bool boolParam)
{
if (!_activitySource.HasListeners())
{
return null!;
}

if (System.Diagnostics.Activity.Current != null)
{
System.Diagnostics.Activity.Current.SetTag("intparam", intParam);
Expand All @@ -60,6 +70,11 @@ public System.Diagnostics.Activity Context(string stringParam, int intParam, boo
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public System.Diagnostics.Activity? ContextWithNullableReturnActivity(string stringParam, int intParam, bool boolParam)
{
if (!_activitySource.HasListeners())
{
return null;
}

if (System.Diagnostics.Activity.Current != null)
{
System.Diagnostics.Activity.Current.SetTag("intparam", intParam);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,22 @@ static void RecordExceptionInternal(System.Diagnostics.Activity? activity, Syste
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public void Activity()
{
if (!_activitySource.HasListeners())
{
return;
}

System.Diagnostics.Activity? activityActivity = _activitySource.StartActivity(name: "Activity", kind: System.Diagnostics.ActivityKind.Internal, parentId: default, tags: default, links: default, startTime: default);
}

[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public void Context(string stringParam, int intParam, bool boolParam)
{
if (!_activitySource.HasListeners())
{
return;
}

if (System.Diagnostics.Activity.Current != null)
{
System.Diagnostics.Activity.Current.SetTag("intparam", intParam);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,22 @@ static void RecordExceptionInternal(System.Diagnostics.Activity? activity, Syste
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public void Activity()
{
if (!_activitySource.HasListeners())
{
return;
}

System.Diagnostics.Activity? activityActivity = _activitySource.StartActivity(name: "Activity", kind: System.Diagnostics.ActivityKind.Internal, parentId: default, tags: default, links: default, startTime: default);
}

[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public void Event(System.Diagnostics.Activity activity, string stringParam, int intParam, bool boolParam)
{
if (!_activitySource.HasListeners())
{
return;
}

if (activity != null)
{
System.Diagnostics.ActivityTagsCollection tagsCollectionEvent = new System.Diagnostics.ActivityTagsCollection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,22 @@ static void RecordExceptionInternal(System.Diagnostics.Activity? activity, Syste
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public void Activity()
{
if (!_activitySource.HasListeners())
{
return;
}

System.Diagnostics.Activity? activityActivity = _activitySource.StartActivity(name: "Activity", kind: System.Diagnostics.ActivityKind.Internal, parentId: default, tags: default, links: default, startTime: default);
}

[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public void Event(System.Diagnostics.Activity? activity, string stringParam, int intParam, bool boolParam)
{
if (!_activitySource.HasListeners())
{
return;
}

if (activity != null)
{
System.Diagnostics.ActivityTagsCollection tagsCollectionEvent = new System.Diagnostics.ActivityTagsCollection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ static void RecordExceptionInternal(System.Diagnostics.Activity? activity, Syste
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public void Activity(string stringParam, int intParam, bool boolParam)
{
if (!_activitySource.HasListeners())
{
return;
}

System.Diagnostics.Activity? activityActivity = _activitySource.StartActivity(name: "Activity", kind: System.Diagnostics.ActivityKind.Internal, parentId: default, tags: default, links: default, startTime: default);

if (activityActivity != null)
Expand All @@ -58,6 +63,11 @@ public void Activity(string stringParam, int intParam, bool boolParam)
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public void Event(string stringParam, int intParam, bool boolParam)
{
if (!_activitySource.HasListeners())
{
return;
}

if (System.Diagnostics.Activity.Current != null)
{
System.Diagnostics.ActivityTagsCollection tagsCollectionEvent = new System.Diagnostics.ActivityTagsCollection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ static void RecordExceptionInternal(System.Diagnostics.Activity? activity, Syste
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public System.Diagnostics.Activity? Activity(string? stringParam, int? intParam, bool? boolParam)
{
if (!_activitySource.HasListeners())
{
return null;
}

System.Diagnostics.Activity? activityActivity = _activitySource.StartActivity(name: "Activity", kind: System.Diagnostics.ActivityKind.Internal, parentId: default, tags: default, links: default, startTime: default);

if (activityActivity != null)
Expand All @@ -60,6 +65,11 @@ static void RecordExceptionInternal(System.Diagnostics.Activity? activity, Syste
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public System.Diagnostics.Activity? ActivityWithNullableParams(string? stringParam, int? intParam, bool? boolParam)
{
if (!_activitySource.HasListeners())
{
return null;
}

System.Diagnostics.Activity? activityActivityWithNullableParams = _activitySource.StartActivity(name: "ActivityWithNullableParams", kind: System.Diagnostics.ActivityKind.Internal, parentId: default, tags: default, links: default, startTime: default);

if (activityActivityWithNullableParams != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ static void RecordExceptionInternal(System.Diagnostics.Activity? activity, Syste
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public System.Diagnostics.Activity Activity(string stringParam, int intParam, bool boolParam)
{
if (!_activitySource.HasListeners())
{
return null!;
}

System.Diagnostics.Activity? activityActivity = _activitySource.StartActivity(name: "Activity", kind: System.Diagnostics.ActivityKind.Internal, parentId: default, tags: default, links: default, startTime: default);

if (activityActivity != null)
Expand All @@ -60,6 +65,11 @@ public System.Diagnostics.Activity Activity(string stringParam, int intParam, bo
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public System.Diagnostics.Activity Event(string stringParam, int intParam, bool boolParam)
{
if (!_activitySource.HasListeners())
{
return null!;
}

if (System.Diagnostics.Activity.Current != null)
{
System.Diagnostics.ActivityTagsCollection tagsCollectionEvent = new System.Diagnostics.ActivityTagsCollection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ static void RecordExceptionInternal(System.Diagnostics.Activity? activity, Syste
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public System.Diagnostics.Activity Activity(string stringParam, int intParam, bool boolParam)
{
if (!_activitySource.HasListeners())
{
return null!;
}

System.Diagnostics.Activity? activityActivity = _activitySource.StartActivity(name: "Activity", kind: System.Diagnostics.ActivityKind.Internal, parentId: default, tags: default, links: default, startTime: default);

if (activityActivity != null)
Expand All @@ -60,6 +65,11 @@ public System.Diagnostics.Activity Activity(string stringParam, int intParam, bo
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public System.Diagnostics.Activity? ActivityWithNullableReturnActivity(string stringParam, int intParam, bool boolParam)
{
if (!_activitySource.HasListeners())
{
return null;
}

System.Diagnostics.Activity? activityActivityWithNullableReturnActivity = _activitySource.StartActivity(name: "ActivityWithNullableReturnActivity", kind: System.Diagnostics.ActivityKind.Internal, parentId: default, tags: default, links: default, startTime: default);

if (activityActivityWithNullableReturnActivity != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ static void RecordExceptionInternal(System.Diagnostics.Activity? activity, Syste
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public void Activity(string stringParam, int intParam, bool boolParam)
{
if (!_activitySource.HasListeners())
{
return;
}

System.Diagnostics.Activity? activityActivity = _activitySource.StartActivity(name: "Activity", kind: System.Diagnostics.ActivityKind.Internal, parentId: default, tags: default, links: default, startTime: default);

if (activityActivity != null)
Expand All @@ -58,6 +63,11 @@ public void Activity(string stringParam, int intParam, bool boolParam)
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public void Event(string stringParam, int intParam, bool boolParam)
{
if (!_activitySource.HasListeners())
{
return;
}

if (System.Diagnostics.Activity.Current != null)
{
System.Diagnostics.ActivityTagsCollection tagsCollectionEvent = new System.Diagnostics.ActivityTagsCollection();
Expand Down
Loading

0 comments on commit 7d23021

Please sign in to comment.