Raised This Month: $ Target: $400
 0% 

Solved a small question: fgets or read_file, which is faster?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
zkfpk6
Member
Join Date: Sep 2017
Old 11-30-2017 , 21:04   a small question: fgets or read_file, which is faster?
Reply With Quote #1

i need read more than 5000 lines..

Last edited by zkfpk6; 12-03-2017 at 19:29.
zkfpk6 is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 12-01-2017 , 05:03   Re: a small question: fgets or read_file, which is faster?
Reply With Quote #2

fgets.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-01-2017 , 06:04   Re: a small question: fgets or read_file, which is faster?
Reply With Quote #3

Don't use read_file/write_file.
__________________
HamletEagle is online now
aron9forever
Veteran Member
Join Date: Feb 2013
Location: Rromania
Old 12-01-2017 , 06:23   Re: a small question: fgets or read_file, which is faster?
Reply With Quote #4

https://wiki.alliedmods.net/Optimizi...)#File_Writing


Quote:
Originally Posted by HamletEagle View Post
Don't use read_file/write_file.
these could use a deprecation warning in 1.8.3 like client_disconnect
__________________
Meanwhile, in 2050:
Quote:
Originally Posted by aron9forever
useless small optimizations
Quote:
Originally Posted by Black Rose View Post
On a map that is 512x512x128 units you end up with 3,355,443,200,000 different "positions". To store each one of those positions individually in the variable "user_or" you need 12 terabytes of memory.
aron9forever is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-01-2017 , 08:09   Re: a small question: fgets or read_file, which is faster?
Reply With Quote #5

Quote:
Originally Posted by aron9forever View Post
https://wiki.alliedmods.net/Optimizi...)#File_Writing




these could use a deprecation warning in 1.8.3 like client_disconnect
I'm not entirely sure, client_disconnect is deprecated because it wasn't working quite right. write_file/read_file are working, they are just inefficient. That's up to Arkshine I guess.
__________________
HamletEagle is online now
DjSoftero
Veteran Member
Join Date: Nov 2014
Location: Lithuania
Old 12-01-2017 , 09:45   Re: a small question: fgets or read_file, which is faster?
Reply With Quote #6

Quote:
Originally Posted by HamletEagle View Post
I'm not entirely sure, client_disconnect is deprecated because it wasn't working quite right. write_file/read_file are working, they are just inefficient. That's up to Arkshine I guess.
so I just wrote crap ton of config file reading just to recode everything. nice
__________________
retired chump
DjSoftero is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 12-03-2017 , 17:50   Re: a small question: fgets or read_file, which is faster?
Reply With Quote #7

read_file/write_file are just inefficient if you need to process them more than one time at once.
__________________
Arkshine is offline
zkfpk6
Member
Join Date: Sep 2017
Old 12-03-2017 , 19:29   Re: a small question: fgets or read_file, which is faster?
Reply With Quote #8

thank u all bro, same as i guess.
zkfpk6 is offline
aron9forever
Veteran Member
Join Date: Feb 2013
Location: Rromania
Old 12-04-2017 , 06:17   Re: a small question: fgets or read_file, which is faster?
Reply With Quote #9

Quote:
Originally Posted by DjSoftero View Post
so I just wrote crap ton of config file reading just to recode everything. nice
shouldn't matter if you only do the file parsing once per map (like to read a config)

Quote:
Originally Posted by HamletEagle View Post
I'm not entirely sure, client_disconnect is deprecated because it wasn't working quite right. write_file/read_file are working, they are just inefficient. That's up to Arkshine I guess.
true, but there is no reason to use *_file instead of f*(), maybe no reason to keep them except backwards compatibility, so it should be avoided for newly written scripts

I'm also considering which topics is google more likely to fetch when people search "amxx write to file" or "amxx read from file", also this tut which popped up for me https://forums.alliedmods.net/showthread.php?t=46218 which although explains both methods quite well, a lot of newbs might be tempted to go for "quick and easy"

this is kind of what happened with mysql_*() functions in PHP, technically not broken but still deprecated due to more secure stuff being added, yet still too many people use it
__________________
Meanwhile, in 2050:
Quote:
Originally Posted by aron9forever
useless small optimizations
Quote:
Originally Posted by Black Rose View Post
On a map that is 512x512x128 units you end up with 3,355,443,200,000 different "positions". To store each one of those positions individually in the variable "user_or" you need 12 terabytes of memory.
aron9forever is offline
zkfpk6
Member
Join Date: Sep 2017
Old 12-04-2017 , 22:46   Re: a small question: fgets or read_file, which is faster?
Reply With Quote #10

Quote:
Originally Posted by aron9forever View Post
shouldn't matter if you only do the file parsing once per map (like to read a config)


true, but there is no reason to use *_file instead of f*(), maybe no reason to keep them except backwards compatibility, so it should be avoided for newly written scripts

I'm also considering which topics is google more likely to fetch when people search "amxx write to file" or "amxx read from file", also this tut which popped up for me https://forums.alliedmods.net/showthread.php?t=46218 which although explains both methods quite well, a lot of newbs might be tempted to go for "quick and easy"

this is kind of what happened with mysql_*() functions in PHP, technically not broken but still deprecated due to more secure stuff being added, yet still too many people use it
yeah i saw that tutorial before i asked, but he didn't say which is more faster...i have a little OCD when write codes lol, i think this is a good things for every programer.
zkfpk6 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:15.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode