forked from SciSharp/NumSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnp.index.cs
More file actions
68 lines (59 loc) · 1.56 KB
/
np.index.cs
File metadata and controls
68 lines (59 loc) · 1.56 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
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Engines;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NumSharp;
namespace NumSharp.Benchmark
{
[SimpleJob(RunStrategy.ColdStart, targetCount: 10)]
[MinColumn, MaxColumn, MeanColumn, MedianColumn]
public class npindex
{
private NDArray nd;
private Shape shape;
[GlobalSetup]
public void Setup()
{
shape = new Shape(1000, 1000);
nd = np.arange(1000 * 1000 * 1.0).reshape(shape);
}
[Benchmark]
public void accessInDtype()
{
double a = 0;
for (int d1 = 0; d1 < shape.Dimensions[0]; d1++)
{
for (int d2 = 0; d2 < shape.Dimensions[1]; d2++)
{
a = (double)nd[d1, d2];
}
}
}
[Benchmark]
public void accessInGeneric()
{
double a = 0;
for (int d1 = 0; d1 < shape.Dimensions[0]; d1++)
{
for (int d2 = 0; d2 < shape.Dimensions[1]; d2++)
{
//a = nd.Data<double>(d1, d2);
}
}
}
[Benchmark]
public void accessInObject()
{
object a = 0;
for (int d1 = 0; d1 < shape.Dimensions[0]; d1++)
{
for (int d2 = 0; d2 < shape.Dimensions[1]; d2++)
{
a = nd[d1, d2];
}
}
}
}
}