Skip to content

Commit c3e5e19

Browse files
authored
Merge pull request #240 from wmjordan/master
Added more benchmarks for boxed types
2 parents 3cbb8b4 + db2818b commit c3e5e19

File tree

3 files changed

+45
-3
lines changed

3 files changed

+45
-3
lines changed

NetJSON.Benchmark.Net5_0/Models/DictionariesBenchmark.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,20 @@
66

77
namespace NetJSON.Benchmark.Net5_0.Models
88
{
9-
public class StringDictionaryBenchmark : Benchmark<Dictionary<string, object>>
9+
public class StringDictionaryBenchmark : Benchmark<Dictionary<string, string>>
1010
{
11-
public StringDictionaryBenchmark() : base(new Dictionary<string, object> {
11+
public StringDictionaryBenchmark() : base(new Dictionary<string, string> {
12+
{ "name", "item 1" },
13+
{ "address", "Max, 12, PYM, LO" },
14+
{ "receiver", "Mike" },
15+
{ "unit", "US$" }
16+
}) {
17+
18+
}
19+
}
20+
public class StringObjectDictionaryBenchmark : Benchmark<Dictionary<string, object>>
21+
{
22+
public StringObjectDictionaryBenchmark() : base(new Dictionary<string, object> {
1223
{ "name", "item 1" },
1324
{ "time", DateTime.Now },
1425
{ "address", "Max, 12, PYM, LO" },

NetJSON.Benchmark.Net5_0/Models/SimpleObjectBenchmark.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,22 @@ public class SimpleObjectBenchmark : Benchmark<SimpleObject>
1111
public SimpleObjectBenchmark() : base (new SimpleObject { ID = 10, Name = "Performance" }) {
1212
}
1313
}
14+
15+
public class Int32Benchmark : Benchmark<int>
16+
{
17+
public Int32Benchmark() : base(3) {
18+
}
19+
}
20+
21+
public class BoxedInt32Benchmark : Benchmark<object>
22+
{
23+
public BoxedInt32Benchmark() : base(3) {
24+
}
25+
}
26+
27+
public class StringObjectBenchmark : Benchmark<string>
28+
{
29+
public StringObjectBenchmark() : base("Hello world") {
30+
}
31+
}
1432
}

NetJSON.Benchmark.Net5_0/Program.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ static void Main(string[] args)
1515
WriteLine("4. Single values");
1616
WriteLine("5. Double values");
1717
WriteLine("6. String dictionary");
18-
WriteLine("Choice benchmark aspect: ");
18+
WriteLine("7. String-object dictionary");
19+
WriteLine("8. Int32-object");
20+
WriteLine("9. String-object");
21+
WriteLine("Type the benchmark number and press Enter key: ");
1922
if (Int32.TryParse(ReadLine(), out int index)) {
2023
switch (index) {
2124
case 1:
@@ -35,6 +38,16 @@ static void Main(string[] args)
3538
return;
3639
case 6:
3740
BenchmarkRunner.Run<StringDictionaryBenchmark>();
41+
return;
42+
case 7:
43+
BenchmarkRunner.Run<StringObjectDictionaryBenchmark>();
44+
return;
45+
case 8:
46+
BenchmarkRunner.Run<Int32Benchmark>();
47+
BenchmarkRunner.Run<BoxedInt32Benchmark>();
48+
return;
49+
case 9:
50+
BenchmarkRunner.Run<StringObjectBenchmark>();
3851
return;
3952
default:
4053
break;

0 commit comments

Comments
 (0)