Pages: 1
  Print  
Author Topic: File operations slow in ENIGMA!  (Read 3091 times)
Offline (Unknown gender) Darkstar2
Posted on: June 26, 2014, 04:39:09 pm
Member
Joined: Jan 2014
Posts: 1238

View Profile Email
Now I now this is same behaviour for another known game development software....... but how about making it actually different in ENIGMA, or adding some new file handling ?

writing or reading binary @ 10MB/20MB is slow when today,s hardware can handle 100MB-200MB+++.
IS there a way to implement more optimised faster file I/O in ENIGMA this is one area we don't need to match GMStudio.



« Last Edit: September 26, 2014, 11:51:46 pm by Darkstar2 » Logged
Offline (Male) Josh @ Dreamland
Reply #1 Posted on: June 26, 2014, 08:56:51 pm

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2950

View Profile Email
You can always just use the C++ functions, you know. Aside from that, the functions are slow because you are only buffering tiny chunks of data at a time, and you're casting it to STL strings. I believe Robert wrote buffer functions; do those not work with files? If not, consider using the C functions or writing wrappers around them (they're extremely simple).

Code: (cpp) [Select]
FILE *f = fopen("yourfile.bin", "rb");
char buf[512];
while (!feof(f)) { // Until at end of file
  size_t read = fread(buf, 1, 512, f); // Read at most 512 bytes
  // process bytes here; `read` bytes were read in total
}
fclose(f);

I suppose you'll want the existing convenience functions which do things like read integers for you. In that case, I'd recommend just adding a file_bin_read_buffer() that does what the above does for large chunks.

In the future, we will likely offer memory mapping functions for that.
« Last Edit: June 26, 2014, 09:03:07 pm by Josh @ Dreamland » Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Unknown gender) Darkstar2
Reply #2 Posted on: June 26, 2014, 09:50:37 pm
Member
Joined: Jan 2014
Posts: 1238

View Profile Email
Thanks Josh I was aware of this, these are from the stdio, but didn't know I could integrate these kind of C++ codes into my projects. :D
Logged
Offline (Male) Goombert
Reply #3 Posted on: June 26, 2014, 10:38:05 pm

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 2993

View Profile
Darkstar2, ENIGMA's current compiler only has problems parsing STL, which is vectors, maps, queue's, and other templates.

Josh, the buffer functions are for networking and have to assume endianess, they are not good for simple read/write operations, and they are also shit. I haven't gotten floats working yet either.
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Pages: 1
  Print