-
-
Notifications
You must be signed in to change notification settings - Fork 203
/
Program.cs
85 lines (74 loc) · 2.41 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using System.Diagnostics;
using Sentry.Profiling;
internal static class Program
{
private static void Main()
{
// Enable the SDK
using (SentrySdk.Init(options =>
{
options.Dsn =
// NOTE: ADD YOUR OWN DSN BELOW so you can see the events in your own Sentry account
"https://eb18e953812b41c3aeb042e666fd3b5c@o447951.ingest.sentry.io/5428537";
options.Debug = true;
// options.AutoSessionTracking = true;
options.IsGlobalModeEnabled = true;
options.EnableTracing = true;
// Make sure to reduce the sampling rate in production.
options.ProfilesSampleRate = 1.0;
// Debugging
options.ShutdownTimeout = TimeSpan.FromMinutes(5);
options.AddIntegration(new ProfilingIntegration(TimeSpan.FromMilliseconds(500)));
}))
{
var tx = SentrySdk.StartTransaction("app", "run");
var count = 10;
for (var i = 0; i < count; i++)
{
FindPrimeNumber(100000);
}
tx.Finish();
var sw = Stopwatch.StartNew();
// Flushing takes 10 seconds consistently?
SentrySdk.Flush(TimeSpan.FromMinutes(5));
Console.WriteLine("Flushed in " + sw.Elapsed);
// is the second profile faster?
tx = SentrySdk.StartTransaction("app", "run");
count = 10;
for (var i = 0; i < count; i++)
{
FindPrimeNumber(100000);
}
tx.Finish();
sw = Stopwatch.StartNew();
// Flushing takes 10 seconds consistently?
SentrySdk.Flush(TimeSpan.FromMinutes(5));
Console.WriteLine("Flushed in " + sw.Elapsed);
} // On Dispose: SDK closed, events queued are flushed/sent to Sentry
}
private static long FindPrimeNumber(int n)
{
int count = 0;
long a = 2;
while (count < n)
{
long b = 2;
int prime = 1;// to check if found a prime
while (b * b <= a)
{
if (a % b == 0)
{
prime = 0;
break;
}
b++;
}
if (prime > 0)
{
count++;
}
a++;
}
return (--a);
}
}