-
-
Notifications
You must be signed in to change notification settings - Fork 230
Expand file tree
/
Copy pathProgram.cs
More file actions
86 lines (75 loc) · 2.43 KB
/
Program.cs
File metadata and controls
86 lines (75 loc) · 2.43 KB
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
86
using System.Diagnostics;
internal static class Program
{
private static void Main()
{
// Enable the SDK
using (SentrySdk.Init(options =>
{
#if !SENTRY_DSN_DEFINED_IN_ENV
// A DSN is required. You can set here in code, or you can set it in the SENTRY_DSN environment variable.
// See https://docs.sentry.io/product/sentry-basics/dsn-explainer/
options.Dsn = SamplesShared.Dsn;
#endif
options.Debug = true;
// options.AutoSessionTracking = true;
options.IsGlobalModeEnabled = true;
options.TracesSampleRate = 1.0;
// Make sure to reduce the sampling rate in production.
options.ProfilesSampleRate = 1.0;
// Debugging
options.ShutdownTimeout = TimeSpan.FromMinutes(5);
options.AddProfilingIntegration(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);
}
}