Stopwatch not giving accurate times

hey everyone, im using stopwatch to measure total milliseconds, but the timing is way off. for example, when increment is 50k for this piece of code, i count 30 seconds irl but the console says 0.1105ms, which is not even close to correct
            List<float> uLSexI = new();
            tools.log("Unsorted Linear Search, EXISTING Item", ConsoleColor.Red);
            foreach (int increment in increments)
            {
                tools.log($"Increment {increment}");
                genItems(increment);
                item[] itemsUnsorted = items.ToArray();
                int existingQ = itemsUnsorted[random(0, itemsUnsorted.Length)].quantity;
                long startTime = Stopwatch.GetTimestamp();
                int indexFound = LinearSearch(itemsUnsorted, existingQ);
                TimeSpan elapsedTime = Stopwatch.GetElapsedTime(startTime);
                tools.log($"Increment {increment} complete in {(float)elapsedTime.TotalMilliseconds}ms ({elapsedTime.TotalSeconds}s)");
                uLSexI.Add((float)elapsedTime.TotalMilliseconds);
            }
image.png
Was this page helpful?