Joseph
Joseph
CC#
Created by Joseph on 9/24/2023 in #help
❔ Different Runtimes
Hello, my code is
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
using System.Text;
using System.Threading.Tasks;

namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
Stopwatch watch = new Stopwatch();
watch.Start();
for (int i = 0; i < 1000; i++)
{
Console.WriteLine(i);
}
watch.Stop();
Console.WriteLine($"Execution Time: {watch.ElapsedMilliseconds} ms");
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
using System.Text;
using System.Threading.Tasks;

namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
Stopwatch watch = new Stopwatch();
watch.Start();
for (int i = 0; i < 1000; i++)
{
Console.WriteLine(i);
}
watch.Stop();
Console.WriteLine($"Execution Time: {watch.ElapsedMilliseconds} ms");
}
}
}
when i run this code with writing dotnet run i get 130 ms when i run run it f5 which is "start debugging" i get 20 ms and when i run it ctrl + f5 which is "run without debugging" i get 13 ms can i ask why different speeds?
6 replies