Next: Allocation Benchmark
Up: Str Class Documentation
Previous: About this Documentation
Contents
Benchmarks
This chapter gives some benchmark results that compare the performance of
the Str
class, char*
strings and the standard C++
string
class in a variety of common string operations. Remember
that a benchmark of this type represents a "snapshot" view of a complex system that
contains many variables. Variables that can influence the result
include:
- Processor, Cache Sizes, Memory Speeds, etc.: These
benchmarks were run using an AMD64 3200+ with 64k of L1 cache, 512K L2 cache, and 1
Gb of DDR400 DRAM.
- Compiler Version and Settings: The compiler was gcc 3.3.5.
The only compiler flag used was
-O2
- Optimization Variability: The gcc optimizer does an
excellent job of converting short
char*
functions into
optimized code, how well this optimization scales to more complicated "real
life" situations is less clear.
- C Library Version: The version used was glibc-2.3.4
- Types of tests: Different test types will bring out different
strengths / weaknesses of each approach. For example, it is possible to make
char*
appear
to have poor performance by over-emphasizing operations that are
when using char*
but under Str
.
The approach here was to choose simple, commonly used
operations for the benchmarks.
- Coding Style: Often more specialized approaches to a given
problem will yield better results but these same approaches can not be
generalized to handle a wider range of problems. For example, when
appending substrings together, performance can be measurably improved if the
maximum length of the final string is known ahead of time. These tests
try to keep to general approaches.
The benchmarking code used is included with Str
under the benchmark
directory.
On to the benchmarks...
Subsections
Next: Allocation Benchmark
Up: Str Class Documentation
Previous: About this Documentation
Contents
2007-05-05