Posts Tagged ‘performance’

Yet more website tweaks

Improve server response time

In my original post about hosting my own blog, I mentioned that Google PageSpeed Insights was complaining about server response time. After some research, I realized that my home page was quite large. It was over 1 MB, mainly because of a particular post which contained some large images. (I was complaining about the way graphics are configured on Windows, and included some large screenshots.) The fix was two parts. First, I cropped two of the screenshots to bring the size down a bit more. Second, I added the “More” tag, which makes users click a “Continue reading” link from the home page if they want to see the whole post.

If you want to measure the page load size on your own blog, clear your browser cache, then open up developer tools. Reload the page. On the “Network” tab (“Net” in Firebug), there is a summary of the number of HTTP requests, the amount of data downloaded, and the time it took.

Add LaTeX and YouTube to WordPress

Recently I found another post that needed some special care. In 2012 I posted about my computer animation project and included a YouTube video and some math equations. These used features unique to by simply pasting the link, it will embed a YouTube video, and by using a special tag, you can include math equations using the popular typesetting language LaTeX. One way to bring these into my blog would be to use’s plugin Jetpack. Jetpack brings a lot of features to, but I didn’t want all of them. Instead, I opted for two small plugins, WP-Latex and YouTube Embed Plus.

For people setting up their own blog, I’d recommend either Jetpack or a combination of smaller plugins to enable these features.

SSD benchmarks

I’ve recently purchased an SSD upgrade for my Asus Eee PC 900 (XP). It will be a size upgrade (from 16 GB to 32 GB) and it should be a speed upgrade as well. I decided to do a benchmark of every SSD I currently own in order to compare their performance.

TL;DR: Jump to the results

The contenders

I have four SSDs. They vary in size, and as we’ll find out, speed.

Short name Size Disk ID Comments
Samsung internal 8 GB SanDisk iSSD P4
64BG external 64 GB M4-CT064 M4SSD2 Crucial M4, connected by USB 3.0
Eee PC internal 16 GB ASUS-PHISON SSD
New Eee PC internal 32 GB STT_RPM32GLSE Super Talent, purchased here

Getting the benchmarks

First, I had to choose a benchmark tool that would benchmark both the internal SSDs (Actually the Samsung internal is soldered onto the motherboard) and the external SSDs. I chose a familiar tool, the Disk Utility in Ubuntu 12.04.3. I used the old version after running into this bug on Disk Utility in newer versions of Ubuntu.

This benchmark tool works well for read benchmarks, but for write benchmarks it has a quirk of wanting the disk to have no partition table. Yep, you’ll have to delete all your partitions as well as the partition table. When I benchmarked the Samsung internal, I had to first backup the disk with Clonezilla, then restore the disk after the benchmark completed.

I benchmarked the first three drives listed above, then upgraded the Eee PC’s drive in order to benchmark it.

Upgrading the Eee PC 900

I upgraded the SSD following the recommendation of this article. So before installing the new SSD, I updated the BIOS. This was fairly straightforward. I went to the ASUS support page for the Eee PC 900 XP and downloaded BIOS version 1006. I unzipped the file, and in order to get it to install, I had to rename the file to 900.ROM. I copied 900.ROM to a 256 MB USB stick, and inserted it in the left USB port. Then, when the POST screen showed, I pressed Alt+F2 and got the BIOS update screen. Pretty cool.

Results and conclusion

Read and write benchmarks for solid state disks
Device Average Read Rate (Mb/s) Average Write Rate (Mb/s) Average Access Time (ms)
Samsung internal 137.0 21.2 0.4
64GB external 200.1 51.7 0.2
Eee PC internal 31.3 9.9 0.7
New Eee PC internal 135.8 23.7 0.5

In conclusion, the Eee PC has enjoyed a decent upgrade. Twice the storage space, and a SSD fast enough to compete with the Samsung internal SSD soldered onto the motherboard!

USB hardware smackdown

Continuing in the vein of my USB 3.0 benchmarks, I’d like to compare the USB 2.0 controller on my Samsung Chronos Series 7 NP700Z3A laptop (purchased in 2012) and my HP Compaq dc7900 CMT desktop (purchased in 2009).

My two flash drives for testing are the SanDisk Cruzer Red and the Kingston DataTraveler 111.

For both machines, I ran Ubuntu 12.04.3 amd64 desktop edition, and used Disk Utility (3.0.2) to perform a read-write benchmark.

Samsung Chronos Series 7 NP700Z3A

Average and maximum read rate for a read-write benchmark on the Samsung laptop
Device and port Maximum Read Rate (MB/s) Average Read Rate (MB/s)
Cruzer in USB 2 port 23.1 22.6
DataTraveler in USB 2 port 33.8 30.3

HP Compaq dc7900 CMT

Average and maximum read rate for a read-write benchmark on the HP desktop
Device and port Maximum Read Rate (MB/s) Average Read Rate (MB/s)
Cruzer in USB 2 port 24.8 24.3
DataTraveler in USB 2 port 40.5 39.4

My conclusion is that the HP desktop has a faster USB 2 controller than the Samsung by 7 MB/s or so, but this is only evident when comparing performance of the Kingston.

Some USB 3.0 benchmarks

After transferring large amounts of data and working with hard drives a lot, it interests me to compare the performance of USB 2.0 and USB 3.0. I have one of each of these ports on my Samsung laptop.

In March 2013, I bought a Kingston DataTraveler 111 8GB, and I wanted to compare it to another flash drive, the SanDisk Cruzer Red 4GB, which I purchased in August 2012. The Kingston is a USB 3.0 flash drive, whereas the Cruzer only supports USB 2.0. The tool I used to compare these two was HD Tune, which is free for read-only benchmarks.

Read benchmarks for USB flash drives
Using the USB 2.0 port Using the USB 3.0 port
SanDisk Cruzer Red Kingston DataTraveler 111 SanDisk Cruzer Red Kingston DataTraveler 111
Transfer Rate: Minimum (MB/sec) 19.0 25.4 20.7 60.4
Transfer Rate: Maximum (MB/sec) 29.7 29.6 29.2 72.2
Transfer Rate: Average (MB/sec) 27.7 26.4 28.3 64.8
Access Time (ms) 0.8 1.0 0.5 0.7

According to Wikipedia’s page on USB, the maximum transfer rate of a USB 2.0 link is 35 MB/s, and we see this port reaching very near that, with maximum transfer rates of 29.6 and 29.7. Without doing multiple trials of any of these experiments, we can see that the Kingston DataTraveler is much faster at reads over a USB 3.0 port than the SanDisk Cruzer on either port. However, the comparative write performance of either of these drives remains to be seen.

Sidenote: My pet peeve about USB ports is that (1) laptop manufacturers place them too close together, and (2) USB flash drive manufacturers make flash drives that take up a large profile. The result is you can only fit one flash drive at a time on the USB ports that have been packed too close together.

Random number generation in Python and C++

When I was writing my evolutionary computing program in Python, I often wondered what would have been different if I had used C++ instead. Execution time would be faster, but development time would be slower. In this post, I’ll compare the performance of the two languages in a program I wrote that simulates 100 million coin flips.

I wrote the first version of the program using Python. Python is a good programming language to use for statistical simulation because it has a built-in random library which implements the Mersenne Twister. I executed this version of the program in both Python 2.7.2 and PyPy 1.7. PyPy is an alternative Python interpreter with improved performance. The Python code can be executed using the different interpreters without modification.

I wrote the second version of the program using C++. C++ has a simple random number generator, rand(), which should not be used for any serious statistical simulation. I used two libraries that implemented the Mersenne Twister. My first C++ version uses the GNU Scientific Library (GSL). I was helped by the GSL documentation and by the GSL example in this post. My second C++ version uses the new random number capabilities in C++11. I was helped by this example of uniform_real_distribution. The C++ code can be executed using the two different libraries by changing a few declarations and function calls.

Here are the results of running the code on my desktop computer:

Version Time
Python 23.9 s
PyPy 6.3 s
C++ using GSL 1.8 s
C++11 21.7 s

So assuming I’m not using C++11 incorrectly, it seems that it has really poor performance. There is a decent performance boost when using PyPy over native Python interpreter. But GSL does the best of all.

The files are available in this github repository.