Another Micro-Optimization Provides Useless Results

One of the things to remember about performance optimizations performed in isolation is that their results are rarely representative of real-world performance results. This article outlines the “findings” of the students at a couple of Canadian universities, and comes to the conclusion that string concatenation in memory is slower than writing the same total number of bytes to disk, one after the other.

String concatenation is a slow and CPU-heavy operation. It drastically affects Micro-Optimization testing when both algorithms do not utilize it.

If you don’t immediately see the issue with the algorithm in which the study is utilizing, it will become apparent shortly. You see, when writing to disk, the students were simply writing X bytes at a time to a location on the disk, moving over, writing more. However, when doing it all in memory, they were implementing string concatenatation. These two operations require vastly different amounts of CPU cycles to complete, adding a variable to the performance equation that was not considered in the evaluation.

If the students were actually comparing disk performance versus memory performance, they should have first created a ramdisk and ran the same code against the ramdisk and the normal filesystem on a hard drive or ssd. By creating the ramdisk, you are able to write to a reserved section of memory using the same codepaths in Java and Python that are used for writing to disk, the only difference being the destination and the drivers for that destination, which is as close as possible to comparing two different storage media.

Related Posts

Jan 9, 2015
3 minutes

Authorize.Net Directpost is Overly Complex

One of the necessary evils that every ecommerce website that wants to accept credit card transactions must deal with is some sort of payment processing company. It just so happens that Authorize.net is one of the largest payment processors around, and they allow you to choose from a few different ways to integrate their payment processing functionality into your website. One of their ways is via DirectPost, which allows an eCommerce website to process a credit card transaction without the credit card information ever being sent through the website’s servers.

Mar 9, 2015
2 minutes

The Top Sign You Hired The Wrong Developer

I have been a part of the interview process at a few different companies now, and there is one thing that I have seen correlate completely with how useless a developer hire is. If the hiring manager ever brings me a resume that mentions how many conferences a candidate attends or gives talks at, I will immediately rule that candidate out for the purposes of the development position I am interviewing for.

Mar 10, 2015
One minute

Authenticate Magento Admin Users

Magento’s admin interface allows you to do the vast majority of everything that you would ever want to do to manage your eCommerce website. However, there are times when the rigidity of the framework makes it difficult for developers to appropriately customize a layout.

One of the things that we have done to combat these limitations is to create a new administration section of the website specifically for the use of developers and other advanced administrators of the site. In order to do this as seamlessly as possible, one of the requirements was to enable current admin users to use the same authenticated session across the standard Magento admin and our new custom admin systems.