[sword-devel] Optimization Challenge I - SWBuf

Troy A. Griffitts sword-devel@crosswire.org
Thu, 17 Jul 2003 17:31:36 -0700


Hey geeks,

	I have a challenge to pose! :)  There is new code in 
sword/tests/swbuftest.cpp that performs speed tests.

I bet you can't make it faster! :)  (actually, I guess I bet you can or 
I wouldn't be posting this email)

SWBuf is our new replacement for the STL std::string class.  It's used 
throughout our engine now, and where we were not allowed to expose STL 
in the API interfaces, now we can expose this class.

It is a very important class and it's methods are called 10's of 
millions of times during a typical run of a sword application.

This means any improvement in speed (even milliseconds) will be 
propagated in such a way as to make a big difference.

I'll perform the ratings on my system in single user mode so it's a fair 
contest.  The current benchmarks are as follows:

[scribe@troyslaptop tests]$ time ./swbuftest > test.log
 

append ch test -------
 

append string test -------
 

subscript access test -------
 

constructor and assign test -------
 

compare test -------
 

real    0m18.378s
user    0m16.030s
sys     0m2.340s


Now, I would suggest saving the time and test.log file from a clean copy 
  run on your system, so you have something for comparison.  If a `diff 
test.log.orig test.log` produces anything, don't even think about 
submitting :)

The files involved should include:

sword/include/swbuf.h
sword/src/utilfuns/swbuf.cpp

and for reference:
sword/tests/swbuftest.cpp
no changes to swbuftest.cpp, please.

And remember our API coding standards for cross-platform compatibility 
and leave the assembly code out :)


Have fun!

	-Troy.