Posted By: TrackingKeks
Performance questions - 02/10/10 15:02
OK, I have 2 questions about the file reading performance.
Is it faster to run 2 functions which read some files at the same moment or one after another?
My second question: Is there a big time difference between reading all the data out of 1 file or out of a few files?
Thank you for your help!
Posted By: Joey
Re: Performance questions - 02/10/10 15:40
it is always faster to access a file without too much seeking (resetting the read head position). with small files there won't be a big difference because of the memory buffering.
and it is always slower to have multiple files, as i said, because of the read head repositioning and the file system overhead (reading the mft, seeking etc.).
but as always, there might be exceptions, depending on what you want to do.
Posted By: TrackingKeks
Re: Performance questions - 02/10/10 16:10
Thank you for answering.
I would like to write a "place system" in my game which places all the entities on a grid so that there is an easy access possible for managing and the build editor.
On the one hand reading needs 1 minute with all the data (at the moment 540 files!!+And how long does writing take?).
On the other hand I think when there is only one file the managing is too complicated.
Posted By: Joey
Re: Performance questions - 02/10/10 16:37
so you store every entity position in a separate file? that's slow. just make up a custom file format and store all your data there.
Posted By: TrackingKeks
Re: Performance questions - 02/10/10 18:53
No, I do it in a different way. I have a map (90x90). The entity type is written in a file with the name of its y position and in the line of its x pos. So there are only 90 files with 90 lines for the type.
Posted By: Joey
Re: Performance questions - 02/11/10 14:54
versteh' ich nicht. du kannst auch deutsch schreiben, wenn du willst.
Posted By: TrackingKeks
Re: Performance questions - 02/12/10 12:08
OK. Ich habe eine große Insel, die mit einem Raster versehen worden ist. Dieses Raster ist in meiner eigenen "Einheit" 90x90 groß, d.h. es können theoretisch 90 Objekte in x-Richtung und 90 Objekte in x-Richtung platziert werden (insg. max. 8100 Objekte platzierbar).
Die Definitionen stehen in 90 Dateien. In jeder der Dateien sind 90 Zahlen, jede Zahl steht für einen Objekttyp. Anhand dieser wird die Welt nach dem Raster aufgebaut.
Es sind 90 Dateien und 90 Definitionen/Zeilen pro Datei, da z.B. in Datei 16 alle Daten für die Y-Spalte vorhanden sind: insg. alle 90 x-Werte.
Beispiel Datei 54:
0 0 6 2 1...
Y-Wert nach Raster 54:
X-Wert 1: kein Objekt
X-Wert 2: kein Objekt
X-Wert 3: Objekt 6
X-Wert 4: Objekt 2
X-Wert 5: Objekt 1
Hoffentlich hast du es jetzt verstanden:)
Posted By: Joey
Re: Performance questions - 02/13/10 13:33
naja den Aufbau der Datei nicht so ganz, ist aber ja auch nicht so wichtig. Was spricht dagegen, einfach ein [90][90]-Array mit was auch immer du darin speichern möchtest zu serialisieren? Hau einfach ein reinterpret_cast<char*> drauf und schreibs byteweise in eine Datei. Der Vorteil: du kannst das Array sehr schnell wieder laden.
Posted By: TrackingKeks
Re: Performance questions - 02/17/10 14:50
OK. ich werde es versuchen. Danke!