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

How can I obtain the addition result of two int variables without using a loop for testing? #2576

Closed
ooosan opened this issue May 24, 2024 · 1 comment

Comments

@ooosan
Copy link

ooosan commented May 24, 2024

    [Benchmark]
    public void IntAddition()
    {
        int a = 10;
        int b = 20;
        int c = a + b;
    }

The running result displays an average of 0.0043ns, which is too small.

@timcassell
Copy link
Collaborator

timcassell commented May 24, 2024

Currently not possible. See #1133 and #1802.

Also, the code you pasted is likely constant-optimized by the JIT, so a zero result would be expected. You would need to use arguments or fields to prevent constant-optimizations.

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

No branches or pull requests

2 participants