102,771 questions
2
votes
2
answers
148
views
Why does calling Thread.Sleep in a loop takes 6 seconds instead of 5?
I implemented this simple loop in C# which runs a 100 times, and in each iteration waits for 50ms.
using System.Diagnostics;
var sw = Stopwatch.StartNew();
for (int i = 0; i < 100; i++)
{
...
0
votes
0
answers
13
views
Unable to run macrobenchmark test with StartupMode.Cold
so i've tried running my own macrobenchmark, also with the android/samples and they both fail on StartupMode.Cold with the following error
java.lang.IllegalStateException: The DROP_SHADER_CACHE ...
0
votes
2
answers
105
views
How to efficiently flush and write large amounts of data to a file using BufferedWriter in Java? [closed]
I'm working on a Java project where I need to write a large number of lines to a file. I know BufferedWriter can improve performance compared to writing character by character, but I am unsure about ...
0
votes
0
answers
130
views
Why does std::unordered_map rehash unpredictably when inserting many elements, and how can I control or optimize it? [closed]
I'm experimenting with std::unordered_map performance in C++20 and noticed that when I insert a large number of elements, the container sometimes rehashes multiple times even though I called reserve() ...
5
votes
1
answer
96
views
What is the performance effect (on x64) of __atomic_fetch_add that ignores its result?
My code is
...
fragment1 // compares several regions in D1$ to D1$/D3$
__atomic_fetch_add(&lock,-1,__ATOMIC_ACQ_REL); // stmt A
fragment2 // moves several regions from D1$/D3$ to D1$
...
0
votes
0
answers
52
views
Chrome profiler frame time clarification
I'm reading this tutorial:
In the Frames section, hover your mouse over one of the green squares. DevTools shows you the FPS for that particular frame. Each frame is probably well below the target of ...
2
votes
1
answer
117
views
What does <string>:2(__init__) have to do with mathematical computations?
I'm in the process of writing some mathematical operations. Here's a sample program to give you an idea of what kind of thing I could be doing:
from dataclasses import dataclass
import random
@...
-2
votes
0
answers
75
views
Slow collision detection in Python [closed]
I am making a particle simulator in Python, and noticed that my collision detection is ruining the performance the most. I am not even sure if this is a thing, but is it possible to tell the GPU to do ...
Best practices
1
vote
2
replies
72
views
Optimising a function by caching the results or removing the function enirely?
In JavaScript, how costly is a function call? I ask because I'm looking at, at the start of a function, checking whether the results have already been calculated and, if so, just use them (assuming ...
Best practices
3
votes
4
replies
146
views
Will std::is_trivially_copyable_v be deprecated by std::is_trivially_relocatable_v since C++26?
The main use of std::is_trivially_copyable_v[1] is to determine if an object array copy/move can be safely and efficiently replaced by std::memcpy.
However, C++26 introduces std::...
Advice
0
votes
5
replies
97
views
Why is FileReader as efficient as BufferedReader in reading 1KB chunks of data?
I was trying to read data (chars) from a large text file (~250MB) in 1KB chunks and was very surprised that reading that file using either FileReader or BufferedReader takes exactly the same time, ...
0
votes
1
answer
61
views
Why does heavy object cloning degrade JS performance even when using structuredClone compared to manual optimization? [closed]
In a high-performance Node.js service, I noticed that structuredClone() introduces unexpected latency spikes when cloning large nested objects (30–50 KB each). Even switching to manual cloning ...
0
votes
2
answers
160
views
MRU structure with fixed number of elements, automatically adapting to LINQ queries
I have a folder containing huge numbers of files in many subfolders, and I want to select the files with a name that matches any of a specified list of patterns (regular expressions). My regular ...
Advice
0
votes
2
replies
76
views
What prevents Javascript memory leaks in software applications?
I was thinking back to WinJS or WinUI with Windows Universal Applications (WUA) from about 10 years ago. I am wondering how it compiled and avoided typical architecture errors. If there is no memory ...
Advice
0
votes
13
replies
223
views
JDK 21 What is the point of wrapping a FileReader/InputStreamReader in a BufferedReader?
Java Tutorials site shows this example when discussing character streams:
//The CopyLines example invokes BufferedReader.readLine and PrintWriter.println to do input and output one line at a time.
...