@@ -10,18 +10,18 @@ namespace Thinktecture.Benchmarks;
10
10
11
11
/*
12
12
13
- 15 .04.2025
13
+ 29 .04.2025
14
14
15
15
.NET 9.0.4
16
16
17
- | Method | Mean | Error | StdDev | Median | Allocated |
18
- |----------------------------- |---------:|---------:|- ---------:|----------:|----------:|
19
- | Real_Enum_StringConverter | 11.34 ms | 1.382 ms | 3.876 ms | 9.640 ms | 7.16 MB |
20
- | SmartEnum_Struct_StringBased | 11.63 ms | 1.485 ms | 4.214 ms | 10.541 ms | 8.51 MB |
21
- | SmartEnum_Class_StringBased | 15.93 ms | 2.599 ms | 7.416 ms | 13.270 ms | 8.21 MB |
22
- | Real_Enum_IntBased | 15.07 ms | 2.923 ms | 8.574 ms | 11.595 ms | 6.67 MB |
23
- | SmartEnum_Struct_IntBased | 16.91 ms | 4.670 ms | 13.399 ms | 10.216 ms | 8.02 MB |
24
- | SmartEnum_Class_IntBased | 20.11 ms | 5.255 ms | 15.078 ms | 12.856 ms | 7.72 MB |
17
+ | Method | Mean | Error | StdDev | Median | Allocated |
18
+ |---------------------------- |---------- :|----------:| ---------:|----------:|----------:|
19
+ | RegularEnum_StringConverter | 13.255 ms | 2.0776 ms | 5.792 ms | 11.534 ms | 7.16 MB |
20
+ | SmartEnum_StringBased | 10.681 ms | 1.2877 ms | 3.611 ms | 9.393 ms | 8.21 MB |
21
+ | RegularEnum_IntBased | 6.979 ms | 0.7776 ms | 2.168 ms | 6.708 ms | 6.67 MB |
22
+ | SmartEnum_IntBased | 8.175 ms | 1.1949 ms | 3.210 ms | 7.129 ms | 7.72 MB |
23
+
24
+
25
25
26
26
27
27
*/
@@ -36,14 +36,14 @@ public class LoadingSmartEnums
36
36
private const int _NUMBER_OF_ENTITIES = 10_000 ;
37
37
private static readonly RealEnum [ ] _enums = Enum . GetValues < RealEnum > ( ) ;
38
38
39
- private readonly Entity_Enum_StringConverter [ ] _Entity_Enum_StringConverter
40
- = Enumerable . Range ( 1 , _NUMBER_OF_ENTITIES ) . Select ( i => new Entity_Enum_StringConverter ( i , _enums [ i % _enums . Length ] ) { Enum = RealEnum . Value1 } ) . ToArray ( ) ;
41
- private readonly Entity_Enum_IntBased [ ] _Entity_Enum_IntBased
42
- = Enumerable . Range ( 1 , _NUMBER_OF_ENTITIES ) . Select ( i => new Entity_Enum_IntBased ( i , _enums [ i % _enums . Length ] ) { Enum = RealEnum . Value1 } ) . ToArray ( ) ;
43
- private readonly Entity_SmartEnum_Class_StringBased [ ] _Entity_SmartEnum_Class_StringBased
44
- = Enumerable . Range ( 1 , _NUMBER_OF_ENTITIES ) . Select ( i => new Entity_SmartEnum_Class_StringBased ( i , TestSmartEnum_Class_StringBased . Items [ i % _enums . Length ] ) { Enum = TestSmartEnum_Class_StringBased . Value1 } ) . ToArray ( ) ;
45
- private readonly Entity_SmartEnum_Class_IntBased [ ] _Entity_SmartEnum_Class_IntBased
46
- = Enumerable . Range ( 1 , _NUMBER_OF_ENTITIES ) . Select ( i => new Entity_SmartEnum_Class_IntBased ( i , TestSmartEnum_Class_IntBased . Items [ i % _enums . Length ] ) { Enum = TestSmartEnum_Class_IntBased . Value1 } ) . ToArray ( ) ;
39
+ private readonly Entity_RegularEnum_StringConverter [ ] _Entity_Enum_StringConverter
40
+ = Enumerable . Range ( 1 , _NUMBER_OF_ENTITIES ) . Select ( i => new Entity_RegularEnum_StringConverter ( i , _enums [ i % _enums . Length ] ) { Enum = RealEnum . Value1 } ) . ToArray ( ) ;
41
+ private readonly Entity_RegularEnum_IntBased [ ] _Entity_Enum_IntBased
42
+ = Enumerable . Range ( 1 , _NUMBER_OF_ENTITIES ) . Select ( i => new Entity_RegularEnum_IntBased ( i , _enums [ i % _enums . Length ] ) { Enum = RealEnum . Value1 } ) . ToArray ( ) ;
43
+ private readonly Entity_SmartEnum_StringBased [ ] _Entity_SmartEnum_Class_StringBased
44
+ = Enumerable . Range ( 1 , _NUMBER_OF_ENTITIES ) . Select ( i => new Entity_SmartEnum_StringBased ( i , TestSmartEnum_Class_StringBased . Items [ i % _enums . Length ] ) { Enum = TestSmartEnum_Class_StringBased . Value1 } ) . ToArray ( ) ;
45
+ private readonly Entity_SmartEnum_IntBased [ ] _Entity_SmartEnum_Class_IntBased
46
+ = Enumerable . Range ( 1 , _NUMBER_OF_ENTITIES ) . Select ( i => new Entity_SmartEnum_IntBased ( i , TestSmartEnum_Class_IntBased . Items [ i % _enums . Length ] ) { Enum = TestSmartEnum_Class_IntBased . Value1 } ) . ToArray ( ) ;
47
47
48
48
[ GlobalSetup ]
49
49
public void Initialize ( )
@@ -55,17 +55,17 @@ public void Initialize()
55
55
_dbContext . Database . OpenConnection ( ) ;
56
56
_dbContext . Database . EnsureCreated ( ) ;
57
57
58
- _dbContext . RemoveRange ( _dbContext . Entity_Enum_StringConverter ) ;
59
- _dbContext . Entity_Enum_StringConverter . AddRange ( _Entity_Enum_StringConverter ) ;
58
+ _dbContext . RemoveRange ( _dbContext . Entity_RegularEnum_StringConverter ) ;
59
+ _dbContext . Entity_RegularEnum_StringConverter . AddRange ( _Entity_Enum_StringConverter ) ;
60
60
61
- _dbContext . RemoveRange ( _dbContext . Entity_Enum_IntBased ) ;
62
- _dbContext . Entity_Enum_IntBased . AddRange ( _Entity_Enum_IntBased ) ;
61
+ _dbContext . RemoveRange ( _dbContext . Entity_RegularEnum_IntBased ) ;
62
+ _dbContext . Entity_RegularEnum_IntBased . AddRange ( _Entity_Enum_IntBased ) ;
63
63
64
- _dbContext . RemoveRange ( _dbContext . Entity_SmartEnum_Class_StringBased ) ;
65
- _dbContext . Entity_SmartEnum_Class_StringBased . AddRange ( _Entity_SmartEnum_Class_StringBased ) ;
64
+ _dbContext . RemoveRange ( _dbContext . Entity_SmartEnum_StringBased ) ;
65
+ _dbContext . Entity_SmartEnum_StringBased . AddRange ( _Entity_SmartEnum_Class_StringBased ) ;
66
66
67
- _dbContext . RemoveRange ( _dbContext . Entity_SmartEnum_Class_IntBased ) ;
68
- _dbContext . Entity_SmartEnum_Class_IntBased . AddRange ( _Entity_SmartEnum_Class_IntBased ) ;
67
+ _dbContext . RemoveRange ( _dbContext . Entity_SmartEnum_IntBased ) ;
68
+ _dbContext . Entity_SmartEnum_IntBased . AddRange ( _Entity_SmartEnum_Class_IntBased ) ;
69
69
70
70
_dbContext . SaveChanges ( ) ;
71
71
}
@@ -84,26 +84,26 @@ public void Dispose()
84
84
}
85
85
86
86
[ Benchmark ]
87
- public async Task Real_Enum_StringConverter ( )
87
+ public async Task RegularEnum_StringConverter ( )
88
88
{
89
- await _dbContext ! . Entity_Enum_StringConverter . ToListAsync ( ) ;
89
+ await _dbContext ! . Entity_RegularEnum_StringConverter . ToListAsync ( ) ;
90
90
}
91
91
92
92
[ Benchmark ]
93
- public async Task SmartEnum_Class_StringBased ( )
93
+ public async Task SmartEnum_StringBased ( )
94
94
{
95
- await _dbContext ! . Entity_SmartEnum_Class_StringBased . ToListAsync ( ) ;
95
+ await _dbContext ! . Entity_SmartEnum_StringBased . ToListAsync ( ) ;
96
96
}
97
97
98
98
[ Benchmark ]
99
- public async Task Real_Enum_IntBased ( )
99
+ public async Task RegularEnum_IntBased ( )
100
100
{
101
- await _dbContext ! . Entity_Enum_IntBased . ToListAsync ( ) ;
101
+ await _dbContext ! . Entity_RegularEnum_IntBased . ToListAsync ( ) ;
102
102
}
103
103
104
104
[ Benchmark ]
105
- public async Task SmartEnum_Class_IntBased ( )
105
+ public async Task SmartEnum_IntBased ( )
106
106
{
107
- await _dbContext ! . Entity_SmartEnum_Class_IntBased . ToListAsync ( ) ;
107
+ await _dbContext ! . Entity_SmartEnum_IntBased . ToListAsync ( ) ;
108
108
}
109
109
}
0 commit comments