Skip to content

Instantly share code, notes, and snippets.

@misode
Last active December 26, 2023 12:22
Show Gist options
  • Save misode/7361ea08fea000fc67c0cb623ce85cc6 to your computer and use it in GitHub Desktop.
Save misode/7361ea08fea000fc67c0cb623ce85cc6 to your computer and use it in GitHub Desktop.

Minecraft commands benchmarks

Each test ranks a list of possible commands from best (most efficient) to worst (least efficient). Lower percentages are better. You can only compare the percentages between the commands in the same test.

These tests were done in a superflat world with no entities except for the player. The only commands running are the ones from the test.

1 Running commands for every player

1.1 All players

A simple tick advancement compared to as @a

Players 1 8 32
advancement 0.28% 0.38% 1.32%
function 0.08% 0.21% 0.41%

1.2 All players with a specific hand item

A tick advancement with a condition compared to as @a[predicate=...]

Players 1 8 32
advancement 0.13% 0.30% 1.19%
function 0.17% 0.27% 0.54%

1.3 All players on the ground

A tick advancement with a nbt condition compared to as @a[nbt={...}]

Players 1 8 32
advancement 0.27% 0.59% 2.20%
function 0.33% 0.42% 1.01%

1.4 All players every second

A location advancement compared to schedule ... 1s

Players 1 8 32
advancement 0.01% 0.06% 0.34%
function 0.03% 0.03% 0.05%

2 Execute

The following tests compare combinations of execute subcommands. In general the rule is to have as few subcommands as possible.

2.1 as @e[...] vs as @e if entity @s[...]

  1. execute as @e[nbt={OnGround:1b}] run ... 39.85%
  2. execute as @e if entity @s[nbt={OnGround:1b}] run ... 50.14%

2.2 if score vs [scores={...}]

  1. execute as @e if entity @s[scores={foo=1..}] 37.02%
  2. execute as @e if score @s foo matches 1.. 39.63%

2.3 if predicate vs [predicate=...]

  1. execute as @e[predicate=foo] run ... 15.49%
  2. execute as @e if predicate foo run ... 20.45%
  3. execute as @e if entity @s[predicate=foo] run ... 23.32%
  4. execute as @e at @s if predicate foo run ... 25.22%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment