forked from SciSharp/NumSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnp.add.cs
More file actions
49 lines (45 loc) · 1.09 KB
/
np.add.cs
File metadata and controls
49 lines (45 loc) · 1.09 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
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Engines;
using NumSharp.Backends.Unmanaged;
using NumSharp.Memory.Pooling;
using NumSharp.Unmanaged.Memory;
using NumSharp.Utilities;
namespace NumSharp.Benchmark
{
[SimpleJob(RunStrategy.ColdStart, targetCount: 50)]
[MinColumn, MaxColumn, MeanColumn, MedianColumn]
[HtmlExporter]
public class npadd
{
double a;
double b;
double c;
[GlobalSetup]
public void Setup()
{
var _ = ScalarMemoryPool.Instance;
var __ = InfoOf<byte>.Size;
var ___ = InfoOf<double>.Size;
b = 3;
a = 0;
c = 5;
}
[Benchmark]
public void NDArray_()
{
NDArray a;
for (double i = 0; i < 10000; i++)
{
a = NDArray.Scalar(b) + NDArray.Scalar(c);
}
}
[Benchmark(Baseline = true)]
public void Direct()
{
for (double i = 0; i < 10000; i++)
{
a = b + c;
}
}
}
}