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

Add performance test for XmlSerializationWriter.WriteTypedPrimitive #2623

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

TrayanZapryanov
Copy link
Contributor

Benchmark used in dotnet/runtime#76436
Maybe merge can wait until owners agree that it is good optimization and deserves benchmark.

@TrayanZapryanov
Copy link
Contributor Author

Hmmm, strange exception.
Is it possible that TimeSpan is not supported in net461 ?

[2022/09/30 11:29:37][INFO] // BeforeActualRun
[2022/09/30 11:29:37][INFO]
[2022/09/30 11:29:37][INFO] System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: The type System.TimeSpan was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.
[2022/09/30 11:29:37][INFO] at System.Xml.Serialization.XmlSerializationWriter.WriteTypedPrimitive(String name, String ns, Object o, Boolean xsiType)
[2022/09/30 11:29:37][INFO] at System.Xml.Tests.Perf_XmlSerializationWriter.AddPrimitives()
[2022/09/30 11:29:37][INFO] at BenchmarkDotNet.Autogenerated.Runnable_734.WorkloadActionUnroll(Int64 invokeCount)
[2022/09/30 11:29:37][INFO] at BenchmarkDotNet.Engines.Engine.RunIteration(IterationData data)
[2022/09/30 11:29:37][INFO] at BenchmarkDotNet.Engines.EngineStage.RunIteration(IterationMode mode, IterationStage stage, Int32 index, Int64 invokeCount, Int32 unrollFactor)
[2022/09/30 11:29:37][INFO] at BenchmarkDotNet.Engines.EngineActualStage.RunSpecific(Int64 invokeCount, IterationMode iterationMode, Int32 iterationCount, Int32 unrollFactor)
[2022/09/30 11:29:37][INFO] at BenchmarkDotNet.Engines.EngineActualStage.Run(Int64 invokeCount, IterationMode iterationMode, Boolean runAuto, Int32 unrollFactor, Boolean forceSpecific)
[2022/09/30 11:29:37][INFO] at BenchmarkDotNet.Engines.Engine.Run()
[2022/09/30 11:29:37][INFO] at BenchmarkDotNet.Autogenerated.Runnable_734.Run(IHost host, String benchmarkName)


private readonly MyXmlSerializationWriter _writer = new MyXmlSerializationWriter();

private static readonly DateTime Now = new DateTime(2022, 9, 30, 9, 4, 15, DateTimeKind.Utc);
Copy link
Member

Choose a reason for hiding this comment

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

I think these shouldn't be static readonly in order to prevent some JIT optimization that otherwise may occur, and to have the benchmarks more realistic (i.e. non constant inputs).

@TrayanZapryanov
Copy link
Contributor Author

I receive some warning at the end :

// * Warnings *
MinIterationTime
Perf_XmlSerializationWriter.AddPrimitives: PowerPlanMode=00000000-0000-0000-0000-000000000000, Toolchain=CoreRun, InvocationCount=1, IterationTime=250.0000 ms, MaxIterationCount=20, MinIterationCount=15, UnrollFactor=1, WarmupCount=1 -> The minimum observed iteration time is 19.3454 ms which is very small. It's recommended to increase it to at least 100.0000 ms using more operations.

What should I change to solve it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants