Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8529261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:59:31+00:00 2026-06-11T08:59:31+00:00

I used to think if a method is inlined, then theoretically it is identical

  • 0

I used to think if a method is inlined, then theoretically it is identical to the merge of the method and the calling method, but the benchmark showed there is slightly difference in performance

e.g. this takes 100ms

    public long TestA()
    {
        long ret = 0;
        for (int n = 0; n < testSize; n++)
        {
            for (int i = 0; i < a; i++)
                for (int j = 0; j < b; j++)
                {
                    ret += myArray[i][j];
                }
        }
        return ret;
    }

this takes 110ms (if I force MethodImplOptions.NoInlining on GetIt then it will be 400ms, so I assume it is auto inlined)

    public long TestB()
    {
        long ret = 0;
        for (int n = 0; n < testSize; n++)
        {
            for (int i = 0; i < a; i++)
                for (int j = 0; j < b; j++)
                {
                    ret += GetIt(i, j);
                }
        }
        return ret;
    }

    int GetIt(int x, int y)
    {
        return myArray[x][y];
    }

OK, I attach a snippet of benchmark function i used

    public static void RunTests(Func<long> myTest)
    {
        const int numTrials = 100;
        Stopwatch sw = new Stopwatch();
        double[] sample = new double[numTrials];

        Console.WriteLine("Checksum is {0:N0}", myTest());

        sw.Start();
        myTest();
        sw.Stop();

        Console.WriteLine("Estimated time per test is {0:N0} ticks\n", sw.ElapsedTicks);
        if (sw.ElapsedTicks < 100)
        {
            Console.WriteLine("Ticks per test is less than 100 ticks. Suggest increase testSize.");
            return;
        }

        if (sw.ElapsedTicks > 10000)
        {
            Console.WriteLine("Ticks per test is more than 10,000 ticks. Suggest decrease testSize.");
            return;
        }

        for (int i = 0; i < numTrials / 3; i++)
        {
            myTest();
        }

        string testName = myTest.Method.Name;
        Console.WriteLine("----> Starting benchmark {0}\n", myTest.Method.Name);
        for (int i = 0; i < numTrials; i++)
        {
            GC.Collect();
            GC.WaitForPendingFinalizers();

            sw.Restart();
            myTest();
            sw.Stop();
            sample[i] = sw.ElapsedTicks;
        }
        double testResult = DataSetAnalysis.Report(sample);
        DataSetAnalysis.ConsistencyAnalyze(sample, 0.1);
        Console.WriteLine();

        for (int j = 0; j < numTrials; j = j + 5)
            Console.WriteLine("{0,8:N0} {1,8:N0} {2,8:N0} {3,8:N0} {4,8:N0}", sample[j], sample[j + 1], sample[j + 2], sample[j + 3], sample[j + 4]);
        Console.WriteLine("\n----> End of benchmark");
    } 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:59:33+00:00Added an answer on June 11, 2026 at 8:59 am

    C# does inline at JIT, so whether inline or not IL doesn’t change.

    MethodImplOptions.NoInlining is not the same as inline keyword in F#

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think both are same, but why are both used in the same method?
I think I may misunderstand why the with command is used. But can any
I'm not very used to programming with flags, but I think I just found
I used to think that an assembly could have only one main() method until
i used this method link:http://compiledexperience.com/blog/posts/binding-html-to-the-web-browser-control but had error message like HTML not found in
This line will not work but I think I have used correct xpath? driver.findElement(By.xpath(//a[contains(@class,'cke_button_bold')])).click();
This is a method that used to be in the controller and I think
I used -[NSDictionary getObjects:andKeys:] method first time, and I discovered there's no policy on
I used to think the db/schema.rb in a Rails project stored the database schema,
A recent question contains a problem that I many times used to think about

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.