Last active
July 6, 2017 15:28
-
-
Save pkuderov/5dee7b6a08631c6a31677310a36a418f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Type: StructPerformance.Program | |
// Assembly: StructPerformance, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null | |
// MVID: 6028B8CC-7F4D-43EF-A8CF-6680A3E9F2CC | |
// Location: C:\Users\PKuderov\Documents\Projects\Tests\MicroTests\StructPerformance\bin\Release\StructPerformance.exe | |
// Sequence point data from C:\Users\PKuderov\Documents\Projects\Tests\MicroTests\StructPerformance\bin\Release\StructPerformance.pdb | |
.class private auto ansi beforefieldinit | |
StructPerformance.Program | |
extends [mscorlib]System.Object | |
{ | |
.method private hidebysig static void | |
Main( | |
string[] args | |
) cil managed | |
{ | |
.entrypoint | |
.maxstack 8 | |
// [10 13 - 10 20] | |
IL_0000: call void StructPerformance.Program::Test() | |
// [11 9 - 11 10] | |
IL_0005: ret | |
} // end of method Program::Main | |
.method public hidebysig static void | |
Test() cil managed | |
{ | |
.maxstack 7 | |
.locals init ( | |
[0] class StructPerformance.Point3Class cl, | |
[1] valuetype StructPerformance.Point3Struct st, | |
[2] valuetype StructPerformance.Point6Struct st6, | |
[3] int32 j, | |
[4] float64 acc, | |
[5] class [System]System.Diagnostics.Stopwatch sw, | |
[6] int32 i, | |
[7] int32 i_V_7, | |
[8] int32 i_V_8, | |
[9] int32 i_V_9, | |
[10] int32 i_V_10, | |
[11] int32 i_V_11, | |
[12] int32 i_V_12, | |
[13] int32 i_V_13 | |
) | |
// [15 13 - 15 50] | |
IL_0000: ldc.r8 11 | |
IL_0009: ldc.r8 12 | |
IL_0012: ldc.r8 13 | |
IL_001b: newobj instance void StructPerformance.Point3Class::.ctor(float64, float64, float64) | |
IL_0020: stloc.0 // cl | |
// [16 13 - 16 51] | |
IL_0021: ldloca.s st | |
IL_0023: ldc.r8 11 | |
IL_002c: ldc.r8 12 | |
IL_0035: ldc.r8 13 | |
IL_003e: call instance void StructPerformance.Point3Struct::.ctor(float64, float64, float64) | |
// [17 13 - 17 52] | |
IL_0043: ldloca.s st6 | |
IL_0045: ldc.r8 11 | |
IL_004e: ldc.r8 12 | |
IL_0057: ldc.r8 13 | |
IL_0060: call instance void StructPerformance.Point6Struct::.ctor(float64, float64, float64) | |
// [21 18 - 21 27] | |
IL_0065: ldc.i4.0 | |
IL_0066: stloc.3 // j | |
IL_0067: br IL_039a | |
// start of loop, entry point: IL_039a | |
// [23 17 - 23 32] | |
IL_006c: ldc.r8 0.0 | |
IL_0075: stloc.s acc | |
// [24 17 - 24 47] | |
IL_0077: call class [System]System.Diagnostics.Stopwatch [System]System.Diagnostics.Stopwatch::StartNew() | |
IL_007c: stloc.s sw | |
// [25 22 - 25 31] | |
IL_007e: ldc.i4.0 | |
IL_007f: stloc.s i | |
IL_0081: br.s IL_0095 | |
// start of loop, entry point: IL_0095 | |
// [27 21 - 27 52] | |
IL_0083: ldloc.s acc | |
IL_0085: ldloc.0 // cl | |
IL_0086: ldloc.0 // cl | |
IL_0087: call float64 StructPerformance.Point3Class::Dot(class StructPerformance.Point3Class, class StructPerformance.Point3Class) | |
IL_008c: add | |
IL_008d: stloc.s acc | |
// [25 40 - 25 43] | |
IL_008f: ldloc.s i | |
IL_0091: ldc.i4.1 | |
IL_0092: add | |
IL_0093: stloc.s i | |
// [25 33 - 25 38] | |
IL_0095: ldloc.s i | |
IL_0097: ldc.i4 100000000 // 0x05f5e100 | |
IL_009c: blt.s IL_0083 | |
// end of loop | |
// [29 17 - 29 94] | |
IL_009e: ldstr "Dot(cl,cl):\t\t{0}ms,\tres: {1}" | |
IL_00a3: ldloc.s sw | |
IL_00a5: callvirt instance int64 [System]System.Diagnostics.Stopwatch::get_ElapsedMilliseconds() | |
IL_00aa: box [mscorlib]System.Int64 | |
IL_00af: ldloc.s acc | |
IL_00b1: box [mscorlib]System.Double | |
IL_00b6: call string [mscorlib]System.String::Format(string, object, object) | |
IL_00bb: call void [mscorlib]System.Console::WriteLine(string) | |
// [31 17 - 31 25] | |
IL_00c0: ldc.r8 0.0 | |
IL_00c9: stloc.s acc | |
// [32 17 - 32 43] | |
IL_00cb: call class [System]System.Diagnostics.Stopwatch [System]System.Diagnostics.Stopwatch::StartNew() | |
IL_00d0: stloc.s sw | |
// [33 22 - 33 31] | |
IL_00d2: ldc.i4.0 | |
IL_00d3: stloc.s i_V_7 | |
IL_00d5: br.s IL_00e9 | |
// start of loop, entry point: IL_00e9 | |
// [35 21 - 35 53] | |
IL_00d7: ldloc.s acc | |
IL_00d9: ldloc.1 // st | |
IL_00da: ldloc.1 // st | |
IL_00db: call float64 StructPerformance.Point3Struct::Dot(valuetype StructPerformance.Point3Struct, valuetype StructPerformance.Point3Struct) | |
IL_00e0: add | |
IL_00e1: stloc.s acc | |
// [33 40 - 33 43] | |
IL_00e3: ldloc.s i_V_7 | |
IL_00e5: ldc.i4.1 | |
IL_00e6: add | |
IL_00e7: stloc.s i_V_7 | |
// [33 33 - 33 38] | |
IL_00e9: ldloc.s i_V_7 | |
IL_00eb: ldc.i4 100000000 // 0x05f5e100 | |
IL_00f0: blt.s IL_00d7 | |
// end of loop | |
// [37 17 - 37 95] | |
IL_00f2: ldstr "Dot(st, st):\t\t{0}ms,\tres: {1}" | |
IL_00f7: ldloc.s sw | |
IL_00f9: callvirt instance int64 [System]System.Diagnostics.Stopwatch::get_ElapsedMilliseconds() | |
IL_00fe: box [mscorlib]System.Int64 | |
IL_0103: ldloc.s acc | |
IL_0105: box [mscorlib]System.Double | |
IL_010a: call string [mscorlib]System.String::Format(string, object, object) | |
IL_010f: call void [mscorlib]System.Console::WriteLine(string) | |
// [39 17 - 39 25] | |
IL_0114: ldc.r8 0.0 | |
IL_011d: stloc.s acc | |
// [40 17 - 40 43] | |
IL_011f: call class [System]System.Diagnostics.Stopwatch [System]System.Diagnostics.Stopwatch::StartNew() | |
IL_0124: stloc.s sw | |
// [41 22 - 41 31] | |
IL_0126: ldc.i4.0 | |
IL_0127: stloc.s i_V_8 | |
IL_0129: br.s IL_013c | |
// start of loop, entry point: IL_013c | |
// [43 21 - 43 48] | |
IL_012b: ldloc.s acc | |
IL_012d: ldloc.0 // cl | |
IL_012e: call float64 StructPerformance.Point3Class::Dot(class StructPerformance.Point3Class) | |
IL_0133: add | |
IL_0134: stloc.s acc | |
// [41 40 - 41 43] | |
IL_0136: ldloc.s i_V_8 | |
IL_0138: ldc.i4.1 | |
IL_0139: add | |
IL_013a: stloc.s i_V_8 | |
// [41 33 - 41 38] | |
IL_013c: ldloc.s i_V_8 | |
IL_013e: ldc.i4 100000000 // 0x05f5e100 | |
IL_0143: blt.s IL_012b | |
// end of loop | |
// [45 17 - 45 91] | |
IL_0145: ldstr "Dot(cl):\t\t{0}ms,\tres: {1}" | |
IL_014a: ldloc.s sw | |
IL_014c: callvirt instance int64 [System]System.Diagnostics.Stopwatch::get_ElapsedMilliseconds() | |
IL_0151: box [mscorlib]System.Int64 | |
IL_0156: ldloc.s acc | |
IL_0158: box [mscorlib]System.Double | |
IL_015d: call string [mscorlib]System.String::Format(string, object, object) | |
IL_0162: call void [mscorlib]System.Console::WriteLine(string) | |
// [47 17 - 47 25] | |
IL_0167: ldc.r8 0.0 | |
IL_0170: stloc.s acc | |
// [48 17 - 48 43] | |
IL_0172: call class [System]System.Diagnostics.Stopwatch [System]System.Diagnostics.Stopwatch::StartNew() | |
IL_0177: stloc.s sw | |
// [49 22 - 49 31] | |
IL_0179: ldc.i4.0 | |
IL_017a: stloc.s i_V_9 | |
IL_017c: br.s IL_018f | |
// start of loop, entry point: IL_018f | |
// [51 21 - 51 49] | |
IL_017e: ldloc.s acc | |
IL_0180: ldloc.1 // st | |
IL_0181: call float64 StructPerformance.Point3Struct::Dot(valuetype StructPerformance.Point3Struct) | |
IL_0186: add | |
IL_0187: stloc.s acc | |
// [49 40 - 49 43] | |
IL_0189: ldloc.s i_V_9 | |
IL_018b: ldc.i4.1 | |
IL_018c: add | |
IL_018d: stloc.s i_V_9 | |
// [49 33 - 49 38] | |
IL_018f: ldloc.s i_V_9 | |
IL_0191: ldc.i4 100000000 // 0x05f5e100 | |
IL_0196: blt.s IL_017e | |
// end of loop | |
// [53 17 - 53 91] | |
IL_0198: ldstr "Dot(st):\t\t{0}ms,\tres: {1}" | |
IL_019d: ldloc.s sw | |
IL_019f: callvirt instance int64 [System]System.Diagnostics.Stopwatch::get_ElapsedMilliseconds() | |
IL_01a4: box [mscorlib]System.Int64 | |
IL_01a9: ldloc.s acc | |
IL_01ab: box [mscorlib]System.Double | |
IL_01b0: call string [mscorlib]System.String::Format(string, object, object) | |
IL_01b5: call void [mscorlib]System.Console::WriteLine(string) | |
// [55 17 - 55 25] | |
IL_01ba: ldc.r8 0.0 | |
IL_01c3: stloc.s acc | |
// [56 17 - 56 43] | |
IL_01c5: call class [System]System.Diagnostics.Stopwatch [System]System.Diagnostics.Stopwatch::StartNew() | |
IL_01ca: stloc.s sw | |
// [57 22 - 57 31] | |
IL_01cc: ldc.i4.0 | |
IL_01cd: stloc.s i_V_10 | |
IL_01cf: br.s IL_01e2 | |
// start of loop, entry point: IL_01e2 | |
// [59 21 - 59 50] | |
IL_01d1: ldloc.s acc | |
IL_01d3: ldloc.2 // st6 | |
IL_01d4: call float64 StructPerformance.Point6Struct::Dot(valuetype StructPerformance.Point6Struct) | |
IL_01d9: add | |
IL_01da: stloc.s acc | |
// [57 40 - 57 43] | |
IL_01dc: ldloc.s i_V_10 | |
IL_01de: ldc.i4.1 | |
IL_01df: add | |
IL_01e0: stloc.s i_V_10 | |
// [57 33 - 57 38] | |
IL_01e2: ldloc.s i_V_10 | |
IL_01e4: ldc.i4 100000000 // 0x05f5e100 | |
IL_01e9: blt.s IL_01d1 | |
// end of loop | |
// [61 17 - 61 92] | |
IL_01eb: ldstr "Dot(st6):\t\t{0}ms,\tres: {1}" | |
IL_01f0: ldloc.s sw | |
IL_01f2: callvirt instance int64 [System]System.Diagnostics.Stopwatch::get_ElapsedMilliseconds() | |
IL_01f7: box [mscorlib]System.Int64 | |
IL_01fc: ldloc.s acc | |
IL_01fe: box [mscorlib]System.Double | |
IL_0203: call string [mscorlib]System.String::Format(string, object, object) | |
IL_0208: call void [mscorlib]System.Console::WriteLine(string) | |
// [63 17 - 63 25] | |
IL_020d: ldc.r8 0.0 | |
IL_0216: stloc.s acc | |
// [64 17 - 64 43] | |
IL_0218: call class [System]System.Diagnostics.Stopwatch [System]System.Diagnostics.Stopwatch::StartNew() | |
IL_021d: stloc.s sw | |
// [65 22 - 65 31] | |
IL_021f: ldc.i4.0 | |
IL_0220: stloc.s i_V_11 | |
IL_0222: br.s IL_026a | |
// start of loop, entry point: IL_026a | |
// [67 21 - 67 50] | |
IL_0224: ldloc.s acc | |
IL_0226: ldc.r8 11 | |
IL_022f: ldc.r8 12 | |
IL_0238: ldc.r8 13 | |
IL_0241: ldc.r8 11 | |
IL_024a: ldc.r8 12 | |
IL_0253: ldc.r8 13 | |
IL_025c: call float64 StructPerformance.Program::Dot(float64, float64, float64, float64, float64, float64) | |
IL_0261: add | |
IL_0262: stloc.s acc | |
// [65 40 - 65 43] | |
IL_0264: ldloc.s i_V_11 | |
IL_0266: ldc.i4.1 | |
IL_0267: add | |
IL_0268: stloc.s i_V_11 | |
// [65 33 - 65 38] | |
IL_026a: ldloc.s i_V_11 | |
IL_026c: ldc.i4 100000000 // 0x05f5e100 | |
IL_0271: blt.s IL_0224 | |
// end of loop | |
// [69 17 - 69 92] | |
IL_0273: ldstr "Dot(xyz):\t\t{0}ms,\tres: {1}" | |
IL_0278: ldloc.s sw | |
IL_027a: callvirt instance int64 [System]System.Diagnostics.Stopwatch::get_ElapsedMilliseconds() | |
IL_027f: box [mscorlib]System.Int64 | |
IL_0284: ldloc.s acc | |
IL_0286: box [mscorlib]System.Double | |
IL_028b: call string [mscorlib]System.String::Format(string, object, object) | |
IL_0290: call void [mscorlib]System.Console::WriteLine(string) | |
// [71 17 - 71 25] | |
IL_0295: ldc.r8 0.0 | |
IL_029e: stloc.s acc | |
// [72 17 - 72 43] | |
IL_02a0: call class [System]System.Diagnostics.Stopwatch [System]System.Diagnostics.Stopwatch::StartNew() | |
IL_02a5: stloc.s sw | |
// [73 22 - 73 31] | |
IL_02a7: ldc.i4.0 | |
IL_02a8: stloc.s i_V_12 | |
IL_02aa: br.s IL_02e0 | |
// start of loop, entry point: IL_02e0 | |
// [75 21 - 75 69] | |
IL_02ac: ldloc.s acc | |
IL_02ae: ldloc.0 // cl | |
IL_02af: callvirt instance float64 StructPerformance.Point3Class::get_X() | |
IL_02b4: ldloc.0 // cl | |
IL_02b5: callvirt instance float64 StructPerformance.Point3Class::get_Y() | |
IL_02ba: ldloc.0 // cl | |
IL_02bb: callvirt instance float64 StructPerformance.Point3Class::get_Z() | |
IL_02c0: ldloc.0 // cl | |
IL_02c1: callvirt instance float64 StructPerformance.Point3Class::get_X() | |
IL_02c6: ldloc.0 // cl | |
IL_02c7: callvirt instance float64 StructPerformance.Point3Class::get_Y() | |
IL_02cc: ldloc.0 // cl | |
IL_02cd: callvirt instance float64 StructPerformance.Point3Class::get_Z() | |
IL_02d2: call float64 StructPerformance.Program::Dot(float64, float64, float64, float64, float64, float64) | |
IL_02d7: add | |
IL_02d8: stloc.s acc | |
// [73 40 - 73 43] | |
IL_02da: ldloc.s i_V_12 | |
IL_02dc: ldc.i4.1 | |
IL_02dd: add | |
IL_02de: stloc.s i_V_12 | |
// [73 33 - 73 38] | |
IL_02e0: ldloc.s i_V_12 | |
IL_02e2: ldc.i4 100000000 // 0x05f5e100 | |
IL_02e7: blt.s IL_02ac | |
// end of loop | |
// [77 17 - 77 95] | |
IL_02e9: ldstr "Dot(cl.xyz):\t\t{0}ms,\tres: {1}" | |
IL_02ee: ldloc.s sw | |
IL_02f0: callvirt instance int64 [System]System.Diagnostics.Stopwatch::get_ElapsedMilliseconds() | |
IL_02f5: box [mscorlib]System.Int64 | |
IL_02fa: ldloc.s acc | |
IL_02fc: box [mscorlib]System.Double | |
IL_0301: call string [mscorlib]System.String::Format(string, object, object) | |
IL_0306: call void [mscorlib]System.Console::WriteLine(string) | |
// [79 17 - 79 25] | |
IL_030b: ldc.r8 0.0 | |
IL_0314: stloc.s acc | |
// [80 17 - 80 43] | |
IL_0316: call class [System]System.Diagnostics.Stopwatch [System]System.Diagnostics.Stopwatch::StartNew() | |
IL_031b: stloc.s sw | |
// [81 22 - 81 31] | |
IL_031d: ldc.i4.0 | |
IL_031e: stloc.s i_V_13 | |
IL_0320: br.s IL_035c | |
// start of loop, entry point: IL_035c | |
// [83 21 - 83 68] | |
IL_0322: ldloc.s acc | |
IL_0324: ldloca.s st | |
IL_0326: call instance float64 StructPerformance.Point3Struct::get_X() | |
IL_032b: ldloca.s st | |
IL_032d: call instance float64 StructPerformance.Point3Struct::get_Y() | |
IL_0332: ldloca.s st | |
IL_0334: call instance float64 StructPerformance.Point3Struct::get_Z() | |
IL_0339: ldloca.s st | |
IL_033b: call instance float64 StructPerformance.Point3Struct::get_X() | |
IL_0340: ldloca.s st | |
IL_0342: call instance float64 StructPerformance.Point3Struct::get_Y() | |
IL_0347: ldloca.s st | |
IL_0349: call instance float64 StructPerformance.Point3Struct::get_Z() | |
IL_034e: call float64 StructPerformance.Program::Dot(float64, float64, float64, float64, float64, float64) | |
IL_0353: add | |
IL_0354: stloc.s acc | |
// [81 40 - 81 43] | |
IL_0356: ldloc.s i_V_13 | |
IL_0358: ldc.i4.1 | |
IL_0359: add | |
IL_035a: stloc.s i_V_13 | |
// [81 33 - 81 38] | |
IL_035c: ldloc.s i_V_13 | |
IL_035e: ldc.i4 100000000 // 0x05f5e100 | |
IL_0363: blt.s IL_0322 | |
// end of loop | |
// [85 17 - 85 95] | |
IL_0365: ldstr "Dot(st.xyz):\t\t{0}ms,\tres: {1}" | |
IL_036a: ldloc.s sw | |
IL_036c: callvirt instance int64 [System]System.Diagnostics.Stopwatch::get_ElapsedMilliseconds() | |
IL_0371: box [mscorlib]System.Int64 | |
IL_0376: ldloc.s acc | |
IL_0378: box [mscorlib]System.Double | |
IL_037d: call string [mscorlib]System.String::Format(string, object, object) | |
IL_0382: call void [mscorlib]System.Console::WriteLine(string) | |
// [87 17 - 87 91] | |
IL_0387: ldstr "____________________________________________________" | |
IL_038c: call void [mscorlib]System.Console::WriteLine(string) | |
// [88 17 - 88 37] | |
IL_0391: call void [mscorlib]System.Console::WriteLine() | |
// [21 36 - 21 39] | |
IL_0396: ldloc.3 // j | |
IL_0397: ldc.i4.1 | |
IL_0398: add | |
IL_0399: stloc.3 // j | |
// [21 29 - 21 34] | |
IL_039a: ldloc.3 // j | |
IL_039b: ldc.i4.5 | |
IL_039c: blt IL_006c | |
// end of loop | |
// [90 9 - 90 10] | |
IL_03a1: ret | |
} // end of method Program::Test | |
.method public hidebysig static float64 | |
Dot( | |
float64 ax, | |
float64 ay, | |
float64 az, | |
float64 bx, | |
float64 by, | |
float64 bz | |
) cil managed | |
{ | |
.maxstack 8 | |
// [94 13 - 94 48] | |
IL_0000: ldarg.0 // ax | |
IL_0001: ldarg.3 // bx | |
IL_0002: mul | |
IL_0003: ldarg.1 // ay | |
IL_0004: ldarg.s by | |
IL_0006: mul | |
IL_0007: add | |
IL_0008: ldarg.2 // az | |
IL_0009: ldarg.s bz | |
IL_000b: mul | |
IL_000c: add | |
IL_000d: ret | |
} // end of method Program::Dot | |
.method public hidebysig specialname rtspecialname instance void | |
.ctor() cil managed | |
{ | |
.maxstack 8 | |
IL_0000: ldarg.0 // this | |
IL_0001: call instance void [mscorlib]System.Object::.ctor() | |
IL_0006: ret | |
} // end of method Program::.ctor | |
} // end of class StructPerformance.Program |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dot(cl,cl): 331ms, res: 43400000000 | |
Dot(st, st): 327ms, res: 43400000000 | |
Dot(cl): 329ms, res: 43400000000 | |
Dot(st): 322ms, res: 43400000000 | |
Dot(st6): 430ms, res: 43400000000 | |
Dot(xyz): 326ms, res: 43400000000 | |
Dot(cl.xyz): 577ms, res: 43400000000 | |
Dot(st.xyz): 479ms, res: 43400000000 | |
____________________________________________________ | |
Dot(cl,cl): 324ms, res: 43400000000 | |
Dot(st, st): 333ms, res: 43400000000 | |
Dot(cl): 332ms, res: 43400000000 | |
Dot(st): 329ms, res: 43400000000 | |
Dot(st6): 431ms, res: 43400000000 | |
Dot(xyz): 328ms, res: 43400000000 | |
Dot(cl.xyz): 583ms, res: 43400000000 | |
Dot(st.xyz): 477ms, res: 43400000000 | |
____________________________________________________ | |
Dot(cl,cl): 327ms, res: 43400000000 | |
Dot(st, st): 329ms, res: 43400000000 | |
Dot(cl): 327ms, res: 43400000000 | |
Dot(st): 330ms, res: 43400000000 | |
Dot(st6): 437ms, res: 43400000000 | |
Dot(xyz): 329ms, res: 43400000000 | |
Dot(cl.xyz): 575ms, res: 43400000000 | |
Dot(st.xyz): 480ms, res: 43400000000 | |
____________________________________________________ | |
Dot(cl,cl): 326ms, res: 43400000000 | |
Dot(st, st): 326ms, res: 43400000000 | |
Dot(cl): 328ms, res: 43400000000 | |
Dot(st): 328ms, res: 43400000000 | |
Dot(st6): 437ms, res: 43400000000 | |
Dot(xyz): 326ms, res: 43400000000 | |
Dot(cl.xyz): 571ms, res: 43400000000 | |
Dot(st.xyz): 479ms, res: 43400000000 | |
____________________________________________________ | |
Dot(cl,cl): 328ms, res: 43400000000 | |
Dot(st, st): 327ms, res: 43400000000 | |
Dot(cl): 330ms, res: 43400000000 | |
Dot(st): 330ms, res: 43400000000 | |
Dot(st6): 440ms, res: 43400000000 | |
Dot(xyz): 330ms, res: 43400000000 | |
Dot(cl.xyz): 574ms, res: 43400000000 | |
Dot(st.xyz): 481ms, res: 43400000000 | |
____________________________________________________ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Diagnostics; | |
namespace StructPerformance | |
{ | |
internal class Program | |
{ | |
private static void Main(string[] args) | |
{ | |
Test(); | |
} | |
public static void Test() | |
{ | |
var cl = new Point3Class(11, 12, 13); | |
var st = new Point3Struct(11, 12, 13); | |
var st6 = new Point6Struct(11, 12, 13); | |
const double x = 11, y = 12, z = 13; | |
const int n = 100000000; | |
for (var j = 0; j < 5; j++) | |
{ | |
double acc = 0; | |
var sw = Stopwatch.StartNew(); | |
for (var i = 0; i < n; i++) | |
{ | |
acc += Point3Class.Dot(cl, cl); | |
} | |
Console.WriteLine($"Dot(cl,cl):\t\t{sw.ElapsedMilliseconds}ms,\tres: {acc}"); | |
acc = 0; | |
sw = Stopwatch.StartNew(); | |
for (var i = 0; i < n; i++) | |
{ | |
acc += Point3Struct.Dot(st, st); | |
} | |
Console.WriteLine($"Dot(st, st):\t\t{sw.ElapsedMilliseconds}ms,\tres: {acc}"); | |
acc = 0; | |
sw = Stopwatch.StartNew(); | |
for (var i = 0; i < n; i++) | |
{ | |
acc += Point3Class.Dot(cl); | |
} | |
Console.WriteLine($"Dot(cl):\t\t{sw.ElapsedMilliseconds}ms,\tres: {acc}"); | |
acc = 0; | |
sw = Stopwatch.StartNew(); | |
for (var i = 0; i < n; i++) | |
{ | |
acc += Point3Struct.Dot(st); | |
} | |
Console.WriteLine($"Dot(st):\t\t{sw.ElapsedMilliseconds}ms,\tres: {acc}"); | |
acc = 0; | |
sw = Stopwatch.StartNew(); | |
for (var i = 0; i < n; i++) | |
{ | |
acc += Point6Struct.Dot(st6); | |
} | |
Console.WriteLine($"Dot(st6):\t\t{sw.ElapsedMilliseconds}ms,\tres: {acc}"); | |
acc = 0; | |
sw = Stopwatch.StartNew(); | |
for (var i = 0; i < n; i++) | |
{ | |
acc += Dot(x, y, z, x, y, z); | |
} | |
Console.WriteLine($"Dot(xyz):\t\t{sw.ElapsedMilliseconds}ms,\tres: {acc}"); | |
acc = 0; | |
sw = Stopwatch.StartNew(); | |
for (var i = 0; i < n; i++) | |
{ | |
acc += Dot(cl.X, cl.Y, cl.Z, cl.X, cl.Y, cl.Z ); | |
} | |
Console.WriteLine($"Dot(cl.xyz):\t\t{sw.ElapsedMilliseconds}ms,\tres: {acc}"); | |
acc = 0; | |
sw = Stopwatch.StartNew(); | |
for (var i = 0; i < n; i++) | |
{ | |
acc += Dot(st.X, st.Y, st.Z, st.X, st.Y, st.Z); | |
} | |
Console.WriteLine($"Dot(st.xyz):\t\t{sw.ElapsedMilliseconds}ms,\tres: {acc}"); | |
Console.WriteLine("____________________________________________________"); | |
Console.WriteLine(); | |
} | |
} | |
public static double Dot(double ax, double ay, double az, double bx, double by, double bz) | |
{ | |
return ax * bx + ay * by + az * bz; | |
} | |
} | |
public class Point3Class | |
{ | |
public double X { get; set; } | |
public double Y { get; set; } | |
public double Z { get; set; } | |
public Point3Class(double x, double y, double z) | |
{ | |
X = x; | |
Y = y; | |
Z = z; | |
} | |
public static double Dot(Point3Class a, Point3Class b) | |
{ | |
return a.X * b.X + a.Y * b.Y + a.Z * b.Z; | |
} | |
public static double Dot(Point3Class a) | |
{ | |
return a.X * a.X + a.Y * a.Y + a.Z * a.Z; | |
} | |
} | |
public struct Point3Struct | |
{ | |
public double X { get; set; } | |
public double Y { get; set; } | |
public double Z { get; set; } | |
public Point3Struct(double x, double y, double z) | |
{ | |
X = x; | |
Y = y; | |
Z = z; | |
} | |
public static double Dot(Point3Struct a, Point3Struct b) | |
{ | |
return a.X * b.X + a.Y * b.Y + a.Z * b.Z; | |
} | |
public static double Dot(Point3Struct a) | |
{ | |
return a.X * a.X + a.Y * a.Y + a.Z * a.Z; | |
} | |
} | |
public struct Point6Struct | |
{ | |
public double X { get; set; } | |
public double Y { get; set; } | |
public double Z { get; set; } | |
public double X1 { get; set; } | |
public double Y1 { get; set; } | |
public double Z1 { get; set; } | |
public Point6Struct(double x, double y, double z) | |
{ | |
X = x; | |
Y = y; | |
Z = z; | |
X1 = x; | |
Y1 = y; | |
Z1 = z; | |
} | |
public static double Dot(Point6Struct a) | |
{ | |
return a.X * a.X1 + a.Y * a.Y1 + a.Z * a.Z1; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment