Nested switch statements

Occasionally, I find myself looking at code with nested switch statements, which need to be modified. For example, the following nested switch statements in MATLAB look at different particle types and charges: A nice way to refactor this is to combine the cases of the nested switch statements: This makes the code cleaner and easier…

Read more Nested switch statements

writing multiple files using multiple threads

Hypothesis: Writing multiple files using multiple threads should be much faster than writing the files without using threads. Experiment: Write 10 files using multi-threading vs single-threading. Results: The following was output on the console with numFiles = 10: Elapsed time for multi-threading: 12 seconds Elapsed time for single-threading: 28 seconds Conclusions: The gains are only…

Read more writing multiple files using multiple threads

lock_guard and unique_lock

I wanted to see the performance comparison of std::lock_guard versus the std::unique_lock. Even though they both provide slightly different implementations and abilities, the performance impact is worth investigating. So, I wrote the following and tested it on my MacBook Air: Here are the typical results: std::lock_guard elapsed time: 29400 microseconds std::unique_lock elapsed time: 29459 microseconds…

Read more lock_guard and unique_lock

sleep

There exists a POSIX C API that can be used to put the program execution on hold for a specified duration. This is done via the sleep command: In C++11, this can be accomplished via the API provided from the thread library:

The Nintendo Switch

Nintendo has once again revolutionized gaming with the release of its new console: the Nintendo Switch. I haven’t had a chance to buy it because it is completely sold out in my neighborhood. The console’s portability is its biggest highlight but I’ve heard there aren’t too many games available for it. Of course, the new…

Read more The Nintendo Switch

AMD’s new Ryzen CPU

In a recent post from Ars Technica: In the Cinebench R15 multithreaded rendering test, AMD says that its new processor scores about 9 percent higher than Intel’s. In the single threaded version of the same test, it’s a dead heat. AMD is back and in March, new benchmarks from various tech outlets can verify their…

Read more AMD’s new Ryzen CPU