Benchmark Scoreboard - ShaneBeee/SkBee GitHub Wiki
Important
All benchmarks on this page include the following:
- 50 players online
- Only the test code shown below is used on the server, no other scripts
- Plugins on the server include Skript, SkBee, Spark and StressTestBots (used to create fake players to test)
This scoreboard updates all players every tick.
This is generally not a good way to do it for multiple reasons:
- Every tick is a bit (ok a LOT) overkill
- We're setting lines of a scoreboard that aren't even changing
Code
on join:
# this is just to setup our fake scores
set {-var::one::%uuid of player%} to 1
set {-var::two::%uuid of player%} to 2
set {-var::three::%uuid of player%} to 3
set {-var::four::%uuid of player%} to 4
every tick:
loop all players:
set title of scoreboard of loop-player to "this is a title"
set line 15 of scoreboard of loop-player to "&7Player:"
set line 14 of scoreboard of loop-player to name of loop-player
set line 13 of scoreboard of loop-player to "Points:"
set line 12 of scoreboard of loop-player to "&7- &b%{-var::one::%uuid of loop-player%}%"
set line 11 of scoreboard of loop-player to "Score:"
set line 10 of scoreboard of loop-player to "&7- &b%{-var::two::%uuid of loop-player%}%"
set line 9 of scoreboard of loop-player to "KDR:"
set line 8 of scoreboard of loop-player to "&7- &b%{-var::three::%uuid of loop-player%}%"
set line 7 of scoreboard of loop-player to "Blerp:"
set line 6 of scoreboard of loop-player to "&7- &b%{-var::four::%uuid of loop-player%}%"
set line 5 of scoreboard of loop-player to "IP: play.myserver.com"
Here is how that code affects the server. Not too bad, but could be better.
This way to do scoreboards spreads out the work load a bit.
Code
on join:
while player is online:
set title of scoreboard of player to "this is a title"
set line 15 of scoreboard of player to "&7Player:"
set line 14 of scoreboard of player to name of player
set line 13 of scoreboard of player to "Points:"
set line 12 of scoreboard of player to "&7- &b%{-var::points::%uuid of player%}%"
set line 11 of scoreboard of player to "Score:"
set line 10 of scoreboard of player to "&7- &b%{-var::score::%uuid of player%}%"
set line 9 of scoreboard of player to "KDR:"
set line 8 of scoreboard of player to "&7- &b%{-var::kdr::%uuid of player%}%"
set line 7 of scoreboard of player to "Blerp:"
set line 6 of scoreboard of player to "&7- &b%{-var::blerp::%uuid of player%}%"
set line 5 of scoreboard of player to "IP: play.myserver.com"
wait 1 tick
Ouchie momma! This one is even higher than the previous one, nearly twice as stressful.
This would be caused due to a massive amount of waits (internally these are scheduled tasks).
In this version, we have created a scoreboard function and only update it when something on the scoreboard actually needs updating.
Code
function updateBoard(p: player):
set title of scoreboard of {_p} to "this is a title"
set line 15 of scoreboard of {_p} to "&7Player:"
set line 14 of scoreboard of {_p} to name of {_p}
set line 13 of scoreboard of {_p} to "Points:"
set line 12 of scoreboard of {_p} to "&7- &b%{-var::points::%uuid of {_p}%}%"
set line 11 of scoreboard of {_p} to "Score:"
set line 10 of scoreboard of {_p} to "&7- &b%{-var::score::%uuid of {_p}%}%"
set line 9 of scoreboard of {_p} to "KDR:"
set line 8 of scoreboard of {_p} to "&7- &b%{-var::kdr::%uuid of {_p}%}%"
set line 7 of scoreboard of {_p} to "Blerp:"
set line 6 of scoreboard of {_p} to "&7- &b%{-var::blerp::%uuid of {_p}%}%"
set line 5 of scoreboard of {_p} to "IP: play.myserver.com"
on join:
updateBoard(player)
on break:
add 1 to {-var::blerp::%uuid of player%}
updateBoard(player)
on place:
add 1 to {-var::points::%uuid of player%}
updateBoard(player)
on death of player:
if attacker is a player:
add 1 to {-var::kdr::%uuid of victim%}
add 1 to {-var::score::%uuid of attacker%}
updateBoard(attacker)
updateBoard(victim)
As you can see in this image, there are significant performance improvements.
(The redacted part is just spark, not significant for this benchmark)