Skip to content

NET6 - Stopwatch.ElapsedMilliseconds returns wrong result when using monoVM on linux-arm #61599

@michaldobrodenka

Description

@michaldobrodenka

Description

Results seem to be 100x bigger.

Reproduction Steps

I was testing minimal Thread.Sleep() time with following program:


Stopwatch sw = new Stopwatch();

while(true)
{
    sw.Restart();
    Thread.Sleep(1);
    sw.Stop();
    Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")} - Elapsed {sw.ElapsedMilliseconds}");
}

deployed with
dotnet publish -r linux-arm -p:PublishTrimmed=True -p:TrimMode=Link --self-contained true -c Release -f net6.0 -o bin\dotnet\mono -p:UseMonoRuntime=true - for monoVM

and
dotnet publish -r linux-arm -p:PublishTrimmed=True -p:TrimMode=Link --self-contained true -c Release -f net6.0 -o bin\dotnet - for default dotnet runtime

Expected behavior

Expected to return number of milliseconds elapsed.

Actual behavior

100x elapsed millisecods for mono VM.

On screenshot first part is using monoVM, second default dotnet runtime.

image

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

Tested on 32bit linux-arm on Yocto linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions