Test out Ascendancy Input Streams!

Started by
7 comments, last by SirLuthor 18 years, 10 months ago
Hello again good people! I bring you, not trials and tribulations, but more junk to test and play with! Anyway, as some of you may or may not know, I've been working for a while now on my engine project, Ascendancy. While it's nowhere near completion yet, I'm getting close now to finishing the core, that is, file functions, memory managment, task managment, utilities, etc. Just recently, I finished my file input streams (couldn't resist a little re-invention of the wheel there [grin]) and have been benchmarking them. Currently, on my machine, they are clearly faster (as much as 400%, in some cases, like when reading with a large chunk size), but I'd like to find out whether this is universal, or whether my machine is simply a highly optimal environment for these operations. That is where you all come in.. I'd like you to download the archive located here, and run the build of the Ascendancy Console within. Here's the deal. There are 4 specific commands which I'd like you (you being whoever has downloaded it, and is going to try this) to try out 5-10 times each, they are these: InputProfile 255InputProfile 1024InputProfile 2048InputProfile Once you've used them all a couple of times, use the logProfiles command, to log the timing results to the 'Time samples.log' file, where you can browse at your lesiure (sp?). Note that these commands (the InputProfile ones, not logProfiles) simply read a file (TimingTest.txt) in in chunks of 1, 255, 1024 and 2048 bytes respectively, and print it out, and the reading is timed, as well as the opening and closing of the file. The functions called in each one are as alike as I can make them, although when the Ascendancy stream is reading, it actually calls it's eof method as well as it's Valid method, whereas the standard stream is only having the eof method called. Once you've done that, I encourage you to format the results, and post em here like this, or simply post the raw log file if you can't be bothered to format it your self.

         Name         | Average Time | Highest Time | Lowest Time 
----------------------|--------------|--------------|-------------
Standard 1 Input      |1.84          |1.91          |1.81         
Ascendancy 1 Input    |1.35          |1.41          |1.20         
----------------------|--------------|--------------|-------------
Standard 255 Input    |0.011         |0.020         |0.010        
Ascendancy 255 Input  |0.007         |0.015         |0.005        
----------------------|--------------|--------------|-------------
Standard 1024 Input   |0.008         |0.010         |0.007        
Ascendancy 1024 Input |0.003         |0.005         |0.003        
----------------------|--------------|--------------|-------------
Standard 2048 Input   |0.008         |0.008         |0.008        
Ascendancy 2048 Input |0.002         |0.003         |0.002        
----------------------|--------------|--------------|-------------

Also, I encourage you to use the help command, and try out the commands therein (regrettably not a full list), seeing if you manage to break anything [smile] It all works fine over here, but as with the streams, I'd like to verify that it works well everywhere else as well, at least at this point. Note that calling the fError command and crashing out with a notifcation and a log entry is not considered 'breaking' it, as that functionality is specifically there [smile] Thanks a lot folks, and if you want to know how my implementation works, feel free to ask, the only reason I'm not posting it right now is that this post is long enough already [grin] This program has only been verified to work on Windows XP though in theory it should also work on some other windows platforms. If you have a version of Windows other then XP, please do try everything out, I'd appreciate it. As the FileInputStream calls Windows API methods directly (as well as some of my other functions) this demo, and indeed Ascendancy, is Windows only.
Free speech for the living, dead men tell no tales,Your laughing finger will never point again...Omerta!Sing for me now!
Advertisement
These timings are from my work PC. I'll run it again when I get home tonight.
- Intel 2.0GHz P4
- 1GB RAM
- Crappy nearly full 40GB 7200RPM drive
- Windows 2K (SP?)


         Name         | Average Time | Highest Time | Lowest Time |----------------------|--------------|--------------|-------------|Standard 1 Input      |1.172         |1.179         |1.165        |Ascendancy 1 Input    |1.137         |1.152         |1.126        |----------------------|--------------|--------------|-------------|Standard 255 Input    |0.015         |0.029         |0.010        |Ascendancy 255 Input  |0.007         |0.009         |0.007        |----------------------|--------------|--------------|-------------|Standard 1024 Input   |0.007         |0.008         |0.007        |Ascendancy 1024 Input |0.004         |0.005         |0.004        |----------------------|--------------|--------------|-------------|Standard 2048 Input   |0.008         |0.016         |0.006        |Ascendancy 2048 Input |0.003         |0.003         |0.003        |----------------------|--------------|--------------|-------------|


[Edited by - pragma Fury on June 7, 2005 7:10:32 PM]
Noted and appreciated [smile] I find it odd however, that your times at 1 byte per read operation are significantly lower then mine with the standard file input, while your timings with Ascendancy input are about the same.. Oh, also, I forgot to mention, please say what OS you were using. I assume you were running WinXP?

Thanks man, and again, any and all are welcome and indeed encouraged to test it out [smile]
Free speech for the living, dead men tell no tales,Your laughing finger will never point again...Omerta!Sing for me now!
Not to dishearten you, or discourage learning, or to say its not possible to out do C++ standard I/O stream & locales in speed its probably quite easy to do considering the amount of stuff that goes on behind a stream for formatted I/O.

I'm just alittle skeptical & curious (as always [grin]) about the results and how the streams where used in code.

For example did you turn off synchronisation with C I/O? e.g.

std::ios_base::sync_with_stdio(false);


In some cases this can dramatically improve performance.

Another thing that needs be considered is how complex the architecture of C++ I/O streams library really is (thats not to say its perfect or good of-course), there is even a ~600 page book on the subject alone. I think most people don't relize this.

The streams are really nothing more than an interface & mediator to whole bunch of things; stream buffers & stream buffer iterators, locale & facet objects, stream callbacks (when used), proper error handling, exceptions (off by default), proper resource & memory management. All these combined allow you to do localized/internationalized formatted I/O.

For unformatted I/O its probably better just to use the stream buffers directly as they deal with the transportation layer (transport of characters to and from an external device) and possible buffering. For example if i remember correctly MinGW's imp of std::basic_filebuf also uses Win32 low-level I/O routines.

This would probably make the test more fair and may even make the results roughly equal.
Sceptical and curious? Yep, in reality, that sums up pretty much every programmer I've seen [grin]

I don't have the codebase here right now, I'll have to try that out tomorrow morning, when I get back to my other PC.. Regarding the complexity of standard streams, yes, I know they do a huge amount of stuff in the background. And going from the info contained in your post, I am led to believe a lot of it is getting data from devices, syncing, formatting, etc. And this is precisely the sort of stuff I don't need to have going on, so I cut it out, when straight up against the windows API, created my own middle layer. Because this is a game engine, I don't need a load of extra junk in my streams. If I want keyboard input, I'll use Direct Input, or whatever other input handler I end up using (are there even any others? I haven't heard of any, to tell you the truth).

As for the usage, well, here's my setup, roughly.. First off, we have a basic InputStream class (as well as an OutputStream, haven't done any work on that or it's derived buddies yet). Now, we have a number of classes inheriting from that InputStream, such as FileInputStream, MemoryInputStream, and their compression and/or encryption reading counterparts. I'm not out to replicate the standard library's streams, with console input, output etc, I'm just making a quick and standardized (for Ascendancy) method for accessing file and memory streams, be they plain, compressed or encrypted. That way, you have a compressed flle? Just open up a Compressed File Input Stream, and read from it as you would a normal file. An encrypted stream of serialized bytes in memory? Opum an Encryption Memory Innput Stream, read from it same as with any other memory or file stream.

I'll try out turning of syncing tomorrow, and post the results, as well as updating the build if necessary.
Free speech for the living, dead men tell no tales,Your laughing finger will never point again...Omerta!Sing for me now!
Quote:Original post by SirLuthor
Noted and appreciated [smile] I find it odd however, that your times at 1 byte per read operation are significantly lower then mine with the standard file input, while your timings with Ascendancy input are about the same.. Oh, also, I forgot to mention, please say what OS you were using. I assume you were running WinXP?

Thanks man, and again, any and all are welcome and indeed encouraged to test it out [smile]


Nope, I was running 2K (not sure what SP) And np. Here are the results from my home computer:
- Windows XP SP2
- Athlon 64 3500+
- 1GB PC4000
- 10K RPM 36GB WD Raptor

         Name         | Average Time | Highest Time | Lowest Time ----------------------|--------------|--------------|-------------Standard 1 Input      |0.756         |0.758         |0.756        Ascendancy 1 Input    |0.722         |0.723         |0.722        ----------------------|--------------|--------------|-------------Standard 255 Input    |0.008         |0.008         |0.008        Ascendancy 255 Input  |0.004         |0.004         |0.004        ----------------------|--------------|--------------|-------------Standard 1024 Input   |0.005         |0.006         |0.005        Ascendancy 1024 Input |0.001         |0.002         |0.001        ----------------------|--------------|--------------|-------------Standard 2048 Input   |0.005         |0.006         |0.005        Ascendancy 2048 Input |0.001         |0.001         |0.001        ----------------------|--------------|--------------|-------------


.. why doesn't the 255InputProfile test conform to the ^2 that the 1024 and 2048 tests do? That is, why isn't it 256InputTest?
Oh, heheh, it's 255, because I made the character buffer a 256 array, remembered that the last character has to be the NULL terminator, and then couldn't be bothered to change all the references to it's size by 1... Also, this way, it's a size that the automatic cache size (65536) doesn't devide by, for whatever it's worth, so you'll get a cache reload in the middle of a read operation, as opposed to at the end of one. Shouldn't make any real difference though.

Did you perchance try out any of the other commands? If so, did every work fine, that is, without crashing or doing something unwarranted?

Ahh, enough for tonight, I'm turning in, it's 1:00 in the morning here...
Free speech for the living, dead men tell no tales,Your laughing finger will never point again...Omerta!Sing for me now!
Hey,

As a sidenote, ctrl-z borks the system causing it to fall into an endless loop of
>_ * Command not recognized.

CJM
Thanks mate, I'll look into that.

[EDIT] I tried out turning off syncing with C I/O, and here are my results:
         Name         | Average Time | Highest Time | Lowest Time ----------------------|--------------|--------------|-------------Standard 1 Input      |1.33          |1.65          |1.18         Ascendancy 1 Input    |0.999         |1.8           |0.991        ----------------------|--------------|--------------|-------------Standard 255 Input    |0.010         |0.010         |0.010        Ascendancy 255 Input  |0.005         |0.006         |0.005        ----------------------|--------------|--------------|-------------Standard 1024 Input   |0.007         |0.007         |0.007        Ascendancy 1024 Input |0.003         |0.003         |0.003        ----------------------|--------------|--------------|-------------Standard 2048 Input   |0.006         |0.006         |0.006        Ascendancy 2048 Input |0.002         |0.002         |0.002        ----------------------|--------------|--------------|-------------

You were definitely right snk_kid, it did have quite a positive effect on the timings of the standard filestreams, but stil not enough [smile] I'll look into trying out the basic_filebuf later on.

[Edited by - SirLuthor on June 8, 2005 7:04:43 AM]
Free speech for the living, dead men tell no tales,Your laughing finger will never point again...Omerta!Sing for me now!

This topic is closed to new replies.

Advertisement