|
what purpose did that serve? how inconsiderate of them smh.
if you don't know what I'm talking about: http://wiki.roblox.com/index.php?title=API:Class/Players/NumPlayers&redirect=no |
|
|
can't you just do numPlayers = #game.Players:GetPlayers() |
|
VulkarinJoin Date: 2013-03-17 Post Count: 282 |
because you can print it in one line who cares..
|
|
|
Its not gotten rid of its deprecated.
Not the same thing.
They shouldn't have in my opinion, it is more efficient to have it than it is to create a table with :GetPlayers() and then get the length of it.
But whatever its not a huge difference. |
|
VulkarinJoin Date: 2013-03-17 Post Count: 282 |
^ You can test it in-game and it's slower
|
|
|
There is no way I can imagine that being true, I'll test it in a minute. |
|
|
#game.Players:GetPlayers() 1 million times takes 0.80861711502075 seconds
game.Players.NumPlayers 1 million times takes 0.49134302139282 seconds |
|
|
'Its not gotten rid of its deprecated.'
doesn't show up in player properties, u sure |
|
VulkarinJoin Date: 2013-03-17 Post Count: 282 |
You have them in reverse...
|
|
|
I just did a test with it so yes I'm sure.
Its a hidden property now. |
|
|
Why would something deprecated show up in the properties? Do you even know how many properties there are hidden from the properties window anyways?
No, they deprecate things otherwise it would break every game in existence.
|
|
|
No, I don't have them reversed. |
|
|
It might be because there's other ways of checking how many players are in a server. GetPlayers (could be) one of them. (One of the reasons I mean.)
function NumPlayersInServer()
return #Game:GetService('Players'):GetPlayers()
end
print(NumPlayersInServer()) -- How many players are in the server.
To ROBLOX, `NumPlayers` may at this point be seen as redundant, and not a lot of use for it anymore. But that's just my guess as to why it was deemed deprecated. |
|
|
"You have them in reverse..."
No, 128 is good at benchmarking.
Besides, you're performing so many more operations with your version than by indexing a property.
|
|
VulkarinJoin Date: 2013-03-17 Post Count: 282 |
Oof I am only saying that because it was the opposite when I ran it but..........
|
|
|
Oh sorry, that's on me I guess.
|
|
|
local tick = tick
do
local start = tick()
for x = 1, 1000000, 1 do
local _ = #game.Players:GetPlayers()
end
print(tick() - start)
end
do
local start = tick()
for x = 1, 1000000, 1 do
local _ = game.Players.NumPlayers
end
print(tick() - start)
end |
|
VulkarinJoin Date: 2013-03-17 Post Count: 282 |
Oh I only did it one time...is that how you are supposed to do it?
|
|
|
Nah, that's like trying to measure a sheet of paper. You can do it, but more likely the inaccuracies of your caliper are going to be the only thing you measure. Measure a whole ream and you can do it accurately with a tape measure.
Do it millions of times to test, that way any minor random fluctuations in speed are negligible.
|
|
|
One call isn't going to give you much information to go on because the speed difference will be small and also since the speed can vary you get a more accurate test the more calls you do
Also even with a single call directly referencing it should still be faster because its doing so much less, so even if you got reversed results I'm betting you probably actually got the scientific notation or whatever its called since the results would have been so small, and read it wrong.
Here are the results of calling it once
1.1920928955078e-05
8.5830688476563e-06
Second one looks like a larger number but it actually is representative of a smaller number than the first represents |
|
ExzeptionJoin Date: 2011-11-01 Post Count: 1312 |
So does anyone know why they deprecated it? |
|
|
Again though, it takes fewer operations anyways. Here's what you get if you thumb through the bytecode.
getglobal -- game
gettable -- .Players
self -- :GetPlayers
call -- ()
len -- #
getglobal -- game
gettable -- .Players
gettable -- .NumPlayers
|
|
|
"So does anyone know why they deprecated it?"
They're on a roll, deprecating things that don't quite match their style expectations. That's good, actually. As I've said for years, their API currently looks like it was written by fifteen interns that don't speak the same language, pushed to github at the same time and the conflicts randomly resolved until it was finished.
|
|
|
I wish they did camelCase though |
|