Skip to content

Environment.TickCount slower on Linux than Windows Core #4755

@ianhays

Description

@ianhays

Environment.TickCount is significantly slower for me on Linux than on Windows running on Core. The following console app:

class Program
{
    static void Main()
    {
        while (true)
        {
            Stopwatch timer = new Stopwatch();
            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();
            int tar;
            timer.Start();
            for (int i = 0; i < 40000; i++)
            {
                tar = Environment.TickCount; tar = Environment.TickCount; tar = Environment.TickCount;
                tar = Environment.TickCount; tar = Environment.TickCount; tar = Environment.TickCount;
                tar = Environment.TickCount; tar = Environment.TickCount; tar = Environment.TickCount;
            }
            timer.Stop();
            Console.WriteLine(timer.Elapsed);
        }
    }
}

runs very fast on Windows 10 Core:

00:00:00.0009579
00:00:00.0009627
00:00:00.0009003
00:00:00.0008818
00:00:00.0009265
00:00:00.0009588
00:00:00.0009627
00:00:00.0008618
00:00:00.0008749
00:00:00.0008869
00:00:00.0008955
00:00:00.0009550
00:00:00.0009576
00:00:00.0008621
00:00:00.0008752
00:00:00.0009063
00:00:00.0009103
00:00:00.0009314
00:00:00.0009320
00:00:00.0009017
00:00:00.0009009
00:00:00.0009411
00:00:00.0009610
00:00:00.0009647
00:00:00.0008772
00:00:00.0009000
00:00:00.0009288
00:00:00.0009596
00:00:00.0009579
00:00:00.0009362
00:00:00.0009071
00:00:00.0009274
00:00:00.0009585
00:00:00.0009576

but significantly slower on Ubuntu 14.04 (running in a VM from the same Windows machine as above):

00:00:00.1984721
00:00:00.2079998
00:00:00.2026383
00:00:00.2145338
00:00:00.2387930
00:00:00.2003931
00:00:00.2382845
00:00:00.2030758
00:00:00.2024682
00:00:00.2017533
00:00:00.2362008
00:00:00.2008249
00:00:00.2379706
00:00:00.2021955
00:00:00.2010206
00:00:00.2210337
00:00:00.2168053
00:00:00.2374686
00:00:00.2016367
00:00:00.2016803
00:00:00.2012516
00:00:00.2384811
00:00:00.2012130
00:00:00.2384954

Related to https://github.com/dotnet/corefx/issues/3572.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions