Tag: performance
-
Bits and bools
One of my friends was wondering about the performance difference between large representations of bools, say bytes, and packed representations of bools, individual bits. Accessing a byte is easier, requiring fewer instructions, but is going to fill up your processor’s cache. Accessing a bit is harder, requiring more instructions, but you can fit more in.…
-
Area of a triangle
This is a bit specific but that is the way with some algorithms, or formulas in this case. Let’s say you want to calculate the area of a triangle. I’m not sure why. It could be something in a graphics shader for a fancy effect. Winging it It’s been a long time since high school…
-
Reorganising data
I’ve talked about data-oriented design before. It looks at structuring things to remove unnecessary data, keep cache refreshes down and thereby get faster code. Compilers are pretty good nowadays at optimising code. That is they can re-order code, inline functions and unroll loops but they’re not going to restructure your data for you. Packing booleans…
-
Saving pennies
Imagine your shopping at a different supermarket from normal. You notice that baked beans are 3p per tin cheaper than you’re use to. The news had a story about supermarket price wars on basic goods recently. It’s a bit out of your way but if you switch supermarkets you could save money on beans each…
-
Iterative development
It can be useful to develop in a series of small steps. At each point trying to write the code that you need but not too much more. Building a huge library that you think you’ll need might be a waste of time but building something small that lets you simplify you current code is…
-
Time complexity
If you’ve had a university education in software engineering you have probably come across algorithmic time complexity. This classifies algorithms by how long they take to run given an known amount of input, normally written using big O notation. Picking an algorithm with a good time complexity can make an enormous difference to the performance…
-
Data-oriented design
I read Data-Oriented Design by Richard Fabian but will mostly cover the methodology (DoD) not the book. Let’s get it out of the way and I’ll try not to belabour it: It’s about all the data Data-oriented design concentrates on the underlying data in any given system. Data tends to be stored in a very…
-
Algorithms are great, minimax
There are problems that are hard to solve. There are problems that are easy to solve if you don’t care about speed. At university the algorithms course was one of my favourites. Finding the right algorithm can mean being able to solve the problem much faster. Maybe you’ll have to discover it yourself but there…
-
Benchmarking tool
I’ve written before about when and how to optimise code. I think there are often more important aspects to a project than code performance. Servers, desktops, laptops and even new mobile phones are many times more powerful than an old computer. Instead you need to decide whether the performance is good enough. That could be…
-
Historic programming style
While researching one of my recent post I came across a reference to The Elements of Programming Style. It’s a study of programming style and it was first published 50 year ago. My dad recognised the book and he remembers when you had to make programs using punched cards! Despite it’s age a lot of…