-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayCreationTasks.cs
More file actions
94 lines (88 loc) · 2.97 KB
/
Copy pathArrayCreationTasks.cs
File metadata and controls
94 lines (88 loc) · 2.97 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
87
88
89
90
91
92
93
94
using System;
using System.Runtime.CompilerServices;
namespace StructBenchmarking
{
public class StructArrayCreationTask : ITask
{
private readonly int size;
private object array;
public StructArrayCreationTask(int size)
{
this.size = size;
}
[MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)]
public void Run()
{
switch (size)
{
case 16:
array = new S16[Constants.ArraySize];
break;
case 32:
array = new S32[Constants.ArraySize];
break;
case 64:
array = new S64[Constants.ArraySize];
break;
case 128:
array = new S128[Constants.ArraySize];
break;
case 256:
array = new S256[Constants.ArraySize];
break;
case 512:
array = new S512[Constants.ArraySize];
break;
default:
throw new ArgumentException();
}
}
}
public class ClassArrayCreationTask : ITask
{
private readonly int size;
public C16[] c16;
public C32[] c32;
public C64[] c64;
public C128[] c128;
public C256[] c256;
public C512[] c512;
public ClassArrayCreationTask(int size)
{
this.size = size;
}
[MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)]
public void Run()
{
switch (size)
{
case 16:
c16 = new C16[Constants.ArraySize];
for (var i = 0; i < Constants.ArraySize; i++) c16[i] = new C16();
break;
case 32:
c32 = new C32[Constants.ArraySize];
for (var i = 0; i < Constants.ArraySize; i++) c32[i] = new C32();
break;
case 64:
c64 = new C64[Constants.ArraySize];
for (var i = 0; i < Constants.ArraySize; i++) c64[i] = new C64();
break;
case 128:
c128 = new C128[Constants.ArraySize];
for (var i = 0; i < Constants.ArraySize; i++) c128[i] = new C128();
break;
case 256:
c256 = new C256[Constants.ArraySize];
for (var i = 0; i < Constants.ArraySize; i++) c256[i] = new C256();
break;
case 512:
c512 = new C512[Constants.ArraySize];
for (var i = 0; i < Constants.ArraySize; i++) c512[i] = new C512();
break;
default:
throw new ArgumentException();
}
}
}
}