[Include] MapAndreas Include
#21

Awesome job, really usefull! waiting to see the speedtest between the plugin and the include.
Reply
#22

Sure:
Код:
Plugin executed 100.000 times in 31 ms
Include executed 100.000 times in 918 ms
Like I already said ~30 times slower. The explanation is on the first page.
Reply
#23

The speed might be improved?

P.S Nice include
Reply
#24

Sexy !
Well done sir
Reply
#25

Quote:
Originally Posted by Anthony_prince
Посмотреть сообщение
The speed might be improved?

P.S Nice include
I'm currently testing some things to possibly improve this. I will write it here if I have something.

Thanks.
Reply
#26

pawn Код:
stock MapAndreas_FindZ_For2DCoord(Float:X, Float:Y, &Float:Z) return GetPointZPos(X, Y, Z);
Little function redefining the function to the actual mapandreas plugin for lazy people that cannot be bothered to convert it (replace)

^ Thats me btw xD ( I use MapAndreas frequently... )

Thanks so much RyDeR`
Reply
#27

pawn Код:
#define MapAndreas_FindZ_For2DCoord GetPointZPos
Should work too.

Thanks for your liking.
Reply
#28

Quote:
Originally Posted by RyDeR`
Посмотреть сообщение
pawn Код:
#define MapAndreas_FindZ_For2DCoord GetPointZPos
Should work too.

Thanks for your liking.
Ohh, I'm dumb lol. Forgot about that as well!
Reply
#29

Quote:
Originally Posted by RyDeR`
Посмотреть сообщение
pawn Код:
#define MapAndreas_FindZ_For2DCoord GetPointZPos
Should work too.

Thanks for your liking.
Possibly can use macros instead this, no?
Reply
#30

Quote:
Originally Posted by iPLEOMAX
Посмотреть сообщение
Awesome work Ryder... You make very useful things everytime.
Thanks.
Yes you are right.
Reply
#31

its dont work with createobjects to find the z height?
Reply
#32

Has anyone else got a mirror on this? SolidFiles seems to have some issues

Edit: Nvm, I apparently already had it installed.
Reply
#33

I slightly updated the code - it should do a bit better now in terms of performance! I also changed the function so it now also returns the result instead of only storing it.

See first post for more information.
Reply
#34

C:\SAMPServer\pawno\include\mapandreas.inc(12) : error 070: rational number support was not enabled
C:\SAMPServer\pawno\include\mapandreas.inc(34) : error 013: no entry point (no public functions)
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Errors.

That's what i call Errors... I copied all the code on the pastebin, the mapandreas pastebin, and i get these errors.... I do not know how to fix them...
Reply
#35

@******, Show me... Can you make a tut?
Reply
#36

Quote:
Originally Posted by ******
Посмотреть сообщение
And I'm still not convinced that this uses less memory since it can't use less memory! ...
Still not sure how this uses the same amount of memory. Well if so, I guess there's an easy fix for that: just close the file when it's not used for like 30 seconds.
Reply
#37

I get 2 errors when trying to Compile the .inc file! line 12 and 34 rational number was not enabled and no entry points
please help! I also do not know where to put the SAFull.hmap file!
Reply
#38

Quote:
Originally Posted by RyDeR`
Посмотреть сообщение
Still not sure how this uses the same amount of memory. Well if so, I guess there's an easy fix for that: just close the file when it's not used for like 30 seconds.
****** explained it very well.. But here is an easier example. If you want to read a text file (as a human), you have to open it, from the moment it is opened it is in the memory. Same happens when you try to read something in pawn. So.. From the moment you open the file (for your fseeking) it will be loaded into the memory. That you don't visually see it opening doesn't mean it doesn't take up the memory.

Closing it doesn't matter that much either.. You just don't use the memory than but you'll still need it when you actually use it. What is the point in the doing that?
Reply
#39

I guess Y-Less isn't correct.
If he would be correct (that opening a file reads the entire file into memory), opening a file of 1.7 Gbytes 1000 times and closing it again would take at least an hour, depending on harddrive speed, would it not?

Код:
    new File:DFile, Count;
	Count = GetTickCount();
	for (new i; i < 1000; i++)
	{
		if (fexist("test.ini"))
		{
		    // Open the FileRadios for reading
			DFile = fopen("test.ini", io_read);
	        // Close the file
			fclose(DFile);
		}
	}
	printf("File took %i ms to open 1000 times and close it again", GetTickCount() - Count);
I put this code inside OnFilterscriptInit and put a file in my scriptfiles folder which is 1.7Gbytes in size.
It's a movie (.mkv file), just renamed to something easier (test.ini), the kind of data in the file doesn't matter as we won't be reading data from it anyway.

I ran this and the result inside my server console was:
Код:
File took 50ms to open 1000 times and close it again
Wow, I must have a very fast harddrive.
Loading a movie-file of 1.7Gbytes for 1000 times.
That's 1.7 Tbytes of data in 50ms.
That would mean my harddrive goes as fast as 34 Terabytes per second reading speed.

Wrong.

Opening a file only lets the OS reserve that file for your program and it returns a filehandle (stored in FileFile in my example) to your program, like a memory-address. After opening the file, the address points to the first byte in the file.
FSeek just sets an offset to that address.
And you can read the data at that location instantly and close the file afterwards.

Why is it slow?
A harddrive cannot read a single byte of data.
It reads an entire sector which is several kilobytes in size and only returns what was asked from that data.
That's the reason why it's slow.
You could read 16Kbytes of data from that sector, even when you only need 1 byte from it.



It's like opening a book.
When someone tells you to open a book (fopen), do you read the entire book instantly after opening it?
Nope.
After opening the book, someone tells you to go to a certain location in the book (fseek).
You do that by going to the given page.
If someone then asks you to read character 900 from that page, can you instantly point to it?
No, you need to read the entire page to find it (read an entire sector).
When you found it, close the book again (fclose).
Did you need to read the entire book to find one value? Nope.
Reply
#40

Nice script work
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)