-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix SerializeStructBenchmark, Serializer not initialized #282
Conversation
} | ||
else | ||
{ | ||
benchmark.Run(args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slight changes so we can pass arguments to BenchmarkDotNet from command line.
RunAll()
is just a shortcut to call Run()
with pre-populated filter argument.
@@ -21,6 +21,7 @@ public class SerializeStructsBenchmark : HyperionBenchmark | |||
|
|||
protected override void Init() | |||
{ | |||
base.Init(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The actual fix, base.Init()
sets the Serializer
field.
@@ -8,8 +8,16 @@ class Program | |||
{ | |||
static void Main(string[] args) | |||
{ | |||
var benchmark = BenchmarkSwitcher.FromAssembly(Assembly.GetExecutingAssembly()); | |||
benchmark.RunAll(); | |||
var benchmark = BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
} | ||
else | ||
{ | ||
benchmark.Run(args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
if (args.Length == 0) | ||
{ | ||
benchmark.RunAll(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hyperion.Benchmarks.SerializeStructsBenchmark did not initialize the
Serializer
field duringInit()
properly, it is null and NRE crashes the benchmark.