Jump to content


Photo

Read File Dll


  • Please log in to reply
24 replies to this topic

#1 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • GMC Elder
  • 9603 posts
  • Version:GM:Studio

Posted 06 July 2007 - 07:12 AM

OK, maybe not infinitely quicker, but darn close. On my laptop, which has a 1.5GHz processor, it ran 170.66 seconds faster than GML (which, if you do the math, is almost 3 minutes faster) reading the example file, which is a little over 2.5MB.

See, when you use GML, how do you read an entire file's contents? The fastest way, sadly, is line-by-line, using GM's already-slow file I/O functionality.

This DLL uses C++'s much-faster I/O functionality, and reads the entire file at once. Hence why it's so much faster :D .

Here's the link: http://h1.ripway.com...a4/ReadFile.zip

It has 2 functions:

file_read_init() - Simply initializes the DLL. Call this ONCE before calling the other function.

file_get_contents(file) - Reads and returns the entire contents of "file". But much more quickly than GML would :P

Included in the ZIP are 5 files:

1) The GML file. This contains the 2 scripts above, so you can put them in any of your own games/programs.

2) The DLL. The most important file :P .

3) The GMK example. This includes an extra script which simply reads the test file the GML way, timing it, then reads it the DLL way, timing it, then returns a few forms of the time difference for you to see.

4) The GM6 version of the example, for those of you who don't have GM7. The DLL works the same no matter which version of GM you use.

5) The TESTING.txt file. This is just a (very repetitive) 2.5MB text file for the example to read. It's just to show you that the DLL is very useful for large files.

NOTE 1: The examples run the GML version before the DLL version, to show the time difference. Since it does start with GML, and it is using a 2.5MB file, it could take a long time. It uses a WHILE loop to make it run as fast as possible, but that also means that once the reading begins, you can't close the program until it's done or you press CTRL+ALT+DEL. Be warned: Don't run the example unless you have the patience to wait for the results.

Come to think of it, that long "pause-time" is actually the reason this DLL was made :P !

Note 2: This DLL is basically useless on small files, since GML can read smaller files fairly quickly. However, on larger files (like files over 1MB) the DLL becomes much faster and much more needed. I don't know where the "cutoff" point is when the DLL becomes useful compared to GML, but I suppose it's somewhere around 1MB, and that it also depends on the computer. I suggest using the DLL in any case, since some computers may be slower than others, so you'll need all the speed you can get :D .

Make sure you look at the code in the examples so that you know: They're not biased either way. They are completely objective, and simply record times. Don't think I rigged it to show a faster time for the DLL :P .

-IMP ;) <_<

*EDIT* Oh, I almost left without telling you guys about the error codes.

Should an error occur with the DLL, it will return an error string instead of the file's contents. This will be one of the following:

"ERROR: Could not open file." - This is self-explanatory, and may be caused by a few things, such as the file being open somewhere else.

"ERROR: Could not create buffer." - This means the memory buffer couldn't be created. I don't know much about buffers, but I believe this should only occur if you don't have enough RAM left to read the size of the file. So make sure if you're reading a 700MB file that you have at least 700MB of RAM left, or you'll get this message. On most modern computers, with standard file sizes, this shouldn't be a problem, and you probably won't get this error very often, if at all.

"ERROR: Could not read from file." - I don't think this will ever happen, but I put the error string in there just in case. Basically, it means the file was opened and the buffer was created, but for whatever reason the contents of the file could not be read. Again, I don't think this will ever happen.

Edited by IceMetalPunk, 06 July 2007 - 07:21 AM.

  • 0

:GM123: Are you an artist who likes creating original creature designs? Maybe you can help out with Elementa here! Give it a look; you might like the idea :)

:bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny:


#2 Daniel-Dane

Daniel-Dane

    GMC Member

  • New Member
  • 3581 posts

Posted 06 July 2007 - 12:23 PM

If I am not mistaken, this DLL will put an entire file into the memory, right?
  • 0

#3 the_doominator

the_doominator

    Eight Star

  • New Member
  • 925 posts

Posted 06 July 2007 - 03:03 PM

As far as I can tell, yes, it does store the entire file's contents into memory.

What if you have a large file, but only want to read the line somewhere in the middle?
  • 0

#4 antidote

antidote

    GMC Member

  • New Member
  • 117 posts

Posted 06 July 2007 - 05:51 PM

You should have the dll open the file and give the user the ability to read one line at a time like GM's slower functions it will only add to the frustration if the programmer can't customize there file readers.
  • 0

#5 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • GMC Elder
  • 9603 posts
  • Version:GM:Studio

Posted 06 July 2007 - 07:07 PM

I'll work on that, but the main point of this DLL is to read an entire file as quickly as possible.

But I'll see what I can do about line-by-line reading.

-IMP :P :(
  • 0

:GM123: Are you an artist who likes creating original creature designs? Maybe you can help out with Elementa here! Give it a look; you might like the idea :)

:bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny:


#6 Daniel-Dane

Daniel-Dane

    GMC Member

  • New Member
  • 3581 posts

Posted 06 July 2007 - 08:15 PM

Yeah, and since the GM strings are pointers, the DLL can't really delete it. Have you thought about that?

GML took 90 seconds, while the DLL took ~16ms.
  • 0

#7 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • GMC Elder
  • 9603 posts
  • Version:GM:Studio

Posted 06 July 2007 - 08:40 PM

Yeah, and since the GM strings are pointers, the DLL can't really delete it. Have you thought about that?

GML took 90 seconds, while the DLL took ~16ms.

<{POST_SNAPBACK}>

I'm not sure what you mean. Why would the DLL need to delete a GM string? If you need to do that, just set the string in GM to "", and GM should deallocate the memory used for it.

And I'm glad you see how fast it was :( But, wow, it only took 90 seconds to read a 2.5MB file with GML for you? You must have a fast computer to start with :P But still, the DLL is faster :GM7: .

-IMP :GM7: :GM7:
  • 0

:GM123: Are you an artist who likes creating original creature designs? Maybe you can help out with Elementa here! Give it a look; you might like the idea :)

:bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny:


#8 Daniel-Dane

Daniel-Dane

    GMC Member

  • New Member
  • 3581 posts

Posted 06 July 2007 - 09:13 PM

It is only 2.4MB.

I mean, since it's a char*, the DLL can't remove or empty the memory. You should explain this to the user.

And it's only a 1.66 GHz Dual core...
  • 0

#9 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • GMC Elder
  • 9603 posts
  • Version:GM:Studio

Posted 06 July 2007 - 09:38 PM

Oh, you mean the memory stored within the DLL itself. Actually, I think it may be possible to empty the memory, since it's in a buffer and it's just converted into PCHAR before sending the result to GM. So memory deallocation may work (although I'm just starting out with C++, so I'll have to study that a little more).

I have a 1.5GHz Celeron processor, and your computer still managed to run twice as fast as mine ;) .

-IMP :) ::lmao::
  • 0

:GM123: Are you an artist who likes creating original creature designs? Maybe you can help out with Elementa here! Give it a look; you might like the idea :)

:bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny:


#10 Randolf The Pirate

Randolf The Pirate

    GMC Member

  • New Member
  • 289 posts

Posted 06 July 2007 - 10:06 PM

The dll seems to be pretty fast. Couldn't run the comparing though because GM version freezed my comptuer completly. Keep up the good work, it could do as it is, but would be useful to have even more functions.
  • 0

#11 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • GMC Elder
  • 9603 posts
  • Version:GM:Studio

Posted 06 July 2007 - 11:42 PM

Thanks ::lmao:: I'm working on getting specific-line reading (and line-by-line reading) into the DLL, although being new, I've run into a slight problem. I've asked Shaltif for help, though, so whenever I get a reply I should be able to get it working and implemented.

-IMP ;) :)
  • 0

:GM123: Are you an artist who likes creating original creature designs? Maybe you can help out with Elementa here! Give it a look; you might like the idea :)

:bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny:


#12 xDanielx

xDanielx

    GMC Member

  • GMC Member
  • 1002 posts
  • Version:Unknown

Posted 07 July 2007 - 12:10 PM

Thumbs up. :whistle:
  • 0

#13 Daniel-Dane

Daniel-Dane

    GMC Member

  • New Member
  • 3581 posts

Posted 07 July 2007 - 05:53 PM

Oh, you mean the memory stored within the DLL itself. Actually, I think it may be possible to empty the memory, since it's in a buffer and it's just converted into PCHAR before sending the result to GM. So memory deallocation may work (although I'm just starting out with C++, so I'll have to study that a little more).

I have a 1.5GHz Celeron processor, and your computer still managed to run twice as fast as mine :P .

-IMP :lol: :whistle:

<{POST_SNAPBACK}>

Well, since GM strings are pointers, the memory should be erased when one empties a GM string, even for the DLL.

Celeron sucks, really much, it is the most suckiest processor ever made. I have a computer with that one too.
  • 0

#14 Relinquished

Relinquished

    GMC Member

  • New Member
  • 265 posts

Posted 08 July 2007 - 10:34 AM

I was gonna make such a thing but since you already beat me to it, hey...why not?
  • 0

#15 zmaj

zmaj

    GMC Member

  • GMC Member
  • 327 posts
  • Version:Unknown

Posted 29 January 2010 - 07:59 AM

pls link is broken or something else...
give us another download adress
  • 0

zmmaj

Leader of ZmajSoft team at

http://www.zmajsoft.com

I-Goo creator and author at

http://i-goo.tk


#16 PlasticineGuy

PlasticineGuy

    GMC Member

  • New Member
  • 2384 posts

Posted 30 January 2010 - 12:14 AM

Two and a half years will do that to a link.
  • 0

#17 IamCalle

IamCalle

    GMC Member

  • GMC Member
  • 444 posts

Posted 30 January 2010 - 01:16 AM

Well, here you go:
-ReadFile download-link- (=
  • 0

#18 Razon

Razon

    GMC Member

  • GMC Member
  • 268 posts
  • Version:GM:Studio

Posted 30 January 2010 - 01:19 AM

If you actually read what it says at the link then you'd realize that it's just temporarily down for 24 hours or so due to bandwidth over usage, unless of course it's been like that for quite a while.

Here's a mirror for it anyway, http://www.mediafire.com/?yn0wmmdduzm.


Edit: Person that posted a link above me didn't upload the full original file for it, my mirror of it is the original file.

Edited by Razon, 30 January 2010 - 01:24 AM.

  • 0

#19 zmaj

zmaj

    GMC Member

  • GMC Member
  • 327 posts
  • Version:Unknown

Posted 07 February 2010 - 10:40 PM

User Account Exceeded Bandwidth ..:)
  • 0

zmmaj

Leader of ZmajSoft team at

http://www.zmajsoft.com

I-Goo creator and author at

http://i-goo.tk


#20 Razon

Razon

    GMC Member

  • GMC Member
  • 268 posts
  • Version:GM:Studio

Posted 08 February 2010 - 12:50 AM

That's why there's the mirror download link that I posted in the post that's just above your's.
  • 0

#21 zmaj

zmaj

    GMC Member

  • GMC Member
  • 327 posts
  • Version:Unknown

Posted 01 March 2010 - 07:34 AM

pls RE upload dll on somewhere else...
This link do NOT seems to work...
tnx
  • 0

zmmaj

Leader of ZmajSoft team at

http://www.zmajsoft.com

I-Goo creator and author at

http://i-goo.tk


#22 PlasticineGuy

PlasticineGuy

    GMC Member

  • New Member
  • 2384 posts

Posted 01 March 2010 - 08:30 AM

http://www.mediafire.com/?yn0wmmdduzm
http://www.megaupload.com/?d=5TS72CGN
  • 0

#23 snowyowl

snowyowl

    GMC Member

  • New Member
  • 615 posts

Posted 01 March 2010 - 09:03 AM

Dammit, guys! Stop posting in two-and-a-half year old topics!
  • 0
Posted Image
Fight time travellers. Kill them three times each.

#24 PlasticineGuy

PlasticineGuy

    GMC Member

  • New Member
  • 2384 posts

Posted 01 March 2010 - 09:13 AM

Bit late for that.
  • 0

#25 raisins

raisins

    GMC Member

  • GMC Member
  • 349 posts
  • Version:GM:Studio

Posted 05 June 2015 - 07:08 PM

Hey, sorry for the necropost but does anyone have a mirror for this? Thanks. :)

 

Edit: whoops, I found the 2.0 topic for this DLL and its got the latest link for it. Sorry about that.


Edited by raisins, 05 June 2015 - 07:10 PM.

  • 0

fxYmZ6o.png

 

Visit my blog for GM tutorials and more! Ask.fm me a question! :D

 

kWb6ZYf.png  Vd9fN4l.png