Closed hugobritobh closed 3 years ago
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.
:white_check_mark: hugobritobh
:x: Hugo de Brito Valadares Rodrigues Alves
Nice Work :)
Just few minor things:
I tried benchmarking the IsNumber method vs the Switch statement and the switch statement is a little faster. (inlining didn't make any difference.)
Method | Mean | Error | StdDev |
---|---|---|---|
IsNumberMethod | 21.15 ns | 0.034 ns | 0.028 ns |
IsNumberInlineMethod | 21.36 ns | 0.079 ns | 0.074 ns |
SwitchStatement | 15.78 ns | 0.050 ns | 0.045 ns |
The benchmark code is here: https://gist.github.com/trampster/117692f09168f262a995b7bb95db29a9
switch statements like this can be compiled into a jump table, which can be executed in a jump instruction. This can beat a two comparisons method like is required in IsNumber.
I think we should leave the switch statements in.
I tried benchmarking the IsNumber method vs the Switch statement and the switch statement is a little faster. (inlining didn't make any difference.)
Method Mean Error StdDev IsNumberMethod 21.15 ns 0.034 ns 0.028 ns IsNumberInlineMethod 21.36 ns 0.079 ns 0.074 ns SwitchStatement 15.78 ns 0.050 ns 0.045 ns The benchmark code is here: https://gist.github.com/trampster/117692f09168f262a995b7bb95db29a9
switch statements like this can be compiled into a jump table, which can be executed in a jump instruction. This can beat a two comparisons method like is required in IsNumber.
I think we should leave the switch statements in.
It could be something from my processor. So, I even made a project for people to test: BenchmarksNumber
Decimal type added
Project Benchmarks added (with BenchmarkDotNet)
IsNumber: code is more readable and this method is faster than Switch
Contains for AttributeSyntax. Example: [assembly: JsonSrcGen.JsonArray(typeof(int))]
Update packages Microsoft.CodeAnalysis.Analyzers (3.3.1) Microsoft.NET.Test.Sdk (16.8.0) NUnit3TestAdapter" Version (3.17.0)
Unit Tests Outcomes 347 Passed 4 Failed (It seems that an error occurred just for me, so it could be a time zone) Do some testing with internationalization (Example: DecimalPropertyTests)