I’m trying to profile a program where certain critical parts have execution time measured in < 50 nanoseconds. I found that my timer class using std::chrono is too expensive (code with timing takes 40% more time than code without). How can I make a faster timer class? I think some OS-specific system calls would be the fastest solution. The platform
Tag: optimization
Why is linear search so much faster than binary search?
Consider the following code to find a peak in an array. If I compile with -O3 and use the linear search solution (the peak function) it takes: If I use the binary search solution which should be much faster (the peak_rec function), it takes: I tried turning off optimization but this didn’t change the situation. I also tried both gcc
What HW resource is mostly used when one does memcpy()?
This feels like a very newbie question, but I suddenly find myself clueless. I’m trying to profile a c application that does a lot of memory copies, and there is an option for me to reduce that number (requires some re-design). I’m trying to realize if it’s worth it, but I have no idea what resource it will affect, or
Optimizing C for loops [closed]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. This question does not appear to be about programming within the scope defined in the help center. Closed 6 years ago. Improve this question I have been trying to optimize my program so far I got down to 8 seconds but my goal its to
Unzipping bz2 file
I have the following command to open a tbz file: The compressed file is about 15 GB and when it is expanded it is about 500GB or so. This operation on an ec2-4x-large operation takes roughly 1h40m. Is there a way to optimize this operation? What would be the fastest way to do the above operation? Answer A couple possibilities
sorting takes 2 hours on vagrant – approx 100m lines
What can I do to optimize this sort? I am running: and then: getting the following output: here’s the datatset that I am using: a preview of the original dataset: here are the details on the vagrant machine: What can I do to optimize this sort? Answer Split your data into several files, sort each file in parallel, then merge