C++ Performance – Counting Clocks

Performance computing can be an interesting task to undertake, as it lets us get under the hood of a complex abstraction (C++) and talk to the machine directly.

In the next two posts we’ll take a look at the Fibonacci algorithm used in a few other posts and see just how fast we can make it by looking at loop implementation, data type usage, and assembly code optimizations. In this first post we’ll take a look at some basic timing code, what gcc will do for us using the -O2 flag, then in the second post, see what we can do (if anything) to improve upon the generated code.

Read More

C++ 64-bit Inline Assembly Primer – Part 2

In this series we examine the relationship and implementations of C++ and raw assembly code. In this post we create our own add function in gcc extended assembly.

In the previous post we wrote a short C++ program that loaded two numbers. Despite its simplicity in C++, we saw how the assembly version was comprised of several dozen individual instructions in a rather cryptic format. Much of this complexity stems from the fact that in our sample program we called a function to perform our addition. Calling functions means dealing with a stack, base pointers, and the setup and maintenance of that stack. It means dealing with memory offsets, relative positions, and several other factors. The good news is that at this point we can safely ignore these details. In fact, we will do well to ignore them and focus on just the core competencies of function implementation code. In other words, we’ll let gcc create the function shells, calls, and stack management, we’ll focus on the core logic.

Read More

C++ 64-bit Inline Assembly Primer – Part 1

We can talk directly to our machines in C++ by inserting assembly code via the asm() or extended assembly __asm__ commands.

Doing so allows us to exploit potential performance gains, learn more about our machines, and is in all cases, a fascinating exercise in the lowest level of computer programming.

In this post I want to share a few tips and tricks I’ve learned when using AT&T style syntax on Linux/gcc, and also explain how basic assembly coding works. We’ll start by creating a simple function and checking out the gcc created assembly code. We’ll then take this apart and step through the code to understand how it works.

Read More

Five Times 2 – HTML 5 For Safari 5

Apple released Safari 5 on June 9th, the fastest and most advanced browser from Apple yet. It’s loaded with new features and enhancements, and from a cursory look, this is an intriguing release indeed.

Thing is though, if your a non-techie all this talk of HTML 5 probably makes you say “Wah?” — While  those of us in the development community are left wondering when we’ll get to implement this cool stuff as the giant elephant in the room sits docilely in the corner.

It’s a confusing release really, filled with more promise and hope than tangible benefit–or is it?

Read More

Porting to the Qt C++ Framework :: Part 4

Having created a shell of our app in step 2, porting the image cleaner code in step 3, we’re now at the stage where we can to port our command line XML cleaner code to Qt. At the end of this post we’ll have a fully functioning C++ Qt app.

Read More

Porting to the Qt C++ Framework :: Part 3

In this part of our series we’ll dive in and start implementing our logic from the command line application to the GUI version.

The goal during this step is to make exclusive use of the Qt frameworks built-in functions and methods for handling these tasks, as the end result must be a cross-platform compatible app.

We’re already getting a valid directory entry from part 2, so the first step in this part is to figure out how we iterate and query files from our base folder.

Read More

Porting to the Qt C++ Framework :: Part 2

In this post I want to introduce the Qt code I’ve written so far. One of the strengths of the Qt framework is its well supported in NetBeans, but more importantly, by Nokia via the Qt Creator IDE. In fact, Nokia supplies a host of tools, from the IDE and language tools, an Interface Designer, and loads of examples.

At the end of this post we’ll have a shell ready for the actual porting process to being. In other words, a GUI that loads, reacts to button presses, and updates status text.

Read More

Porting to the Qt C++ Framework :: Part 1

In this post we’ll start the process of porting a simple command line C++ application to the Nokia Qt framework. Well take a quick look at the code in question, then talk about how we’ll port it.

The application in question is a simple tool for cleaning up the export of a Print Publishing CMS system for eventual use in a Web-based CMS. By simple I mean we open a folder and loop through it, diving into sub-folders as needed to:

  1. Remove all images tagged with a _bw_
  2. Open XML ’story’ files and remove extra line breaks from headline elements, and clean up content HTML.

The application started as an Apple Xcode project, and has now moved into NetBeans 6.8 on Linux. In the end I hope to learn a good deal about the Qt framework, as well as proper C++ application development.

Read More

Multi-Threaded JavaScript — A Quick Look.

The strange thing about this post is that this isn’t exactly news–ever since FireFox 3.5 came out in June of ‘09, and along with Safari 4 and Google Chrome using a slightly different mechanism, these browsers all support OS Level multi-threading.

The question is, should you care?

Read More

Posix Threads In C++

It’s sometimes hard to find a good example of working with threads in C++. Thus, in the course of implementing a very simple working example I decided it wouldn’t hurt to post what I came up with.

Read More