Skip to content
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

Merged
merged 1 commit into from
Jan 11, 2022

Conversation

Arkatufus
Copy link
Contributor

@Arkatufus Arkatufus commented Jan 11, 2022

Hyperion.Benchmarks.SerializeStructsBenchmark did not initialize the Serializer field during Init() properly, it is null and NRE crashes the benchmark.

}
else
{
benchmark.Run(args);
Copy link
Contributor Author

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();
Copy link
Contributor Author

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);
Copy link
Contributor

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);
Copy link
Contributor

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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Arkatufus Arkatufus merged commit 7a78155 into akkadotnet:dev Jan 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants