SkriptLang / Skript

Skript is a Spigot plugin which allows server admins to customize their server easily, but without the hassle of programming a plugin or asking/paying someone to program a plugin for them.
https://docs.skriptlang.org
GNU General Public License v3.0
1.08k stars 373 forks source link

[suggestion] - Add benchmark #3125

Closed Olyno closed 1 year ago

Olyno commented 4 years ago

Description

Sometimes I'm asking myself how long or fast is Skript's parser, or simply syntaxes things like inventories. Maybe adding a benchmark system could be a benefit like a no regression test.

FranKusmiruk commented 4 years ago

Users don't really know how to benchmark properly so that information has little to no use to us or the users, it'll just incentive people making flawed benchmarks to come here and complain about how slow an expression/effect takes. I personally don't like the idea.

Olyno commented 4 years ago

Indeed people could trash talk about the speed of Skript. BUT, it's a good opportinity to improve it and improve the global code of Skript (like if an effect is really slow, how make it faster). With a benchmark, we can see all progress we do (What was the result before? What is the current? Is it better? Why isn't better? ...) Plus, a benchmark is a good opportunity to show that Skript isn't slow and make a great job.

Here is the benchmark I did:

command benchmark:
    trigger:
        set {_initialValue} to 0

        set {_setTime} to now

        loop 5000000 times:
            set {_initialValue} to {_initialValue} + 1

        set {_setTime} to difference between {_setTime} and now
        set {_addTime} to now

        loop 5000000 times:
            add 1 to {_initialValue}

        set {_addTime} to difference between {_addTime} and now
        set {_removeTime} to now

        loop 5000000 times:
            remove 1 from {_initialValue}

        set {_removeTime} to difference between {_removeTime} and now

        broadcast "&bSet 5 000 000 times: %{_setTime}%"
        broadcast "&aAdd 5 000 000 times: %{_addTime}%"
        broadcast "&cRemove 5 000 000 times: %{_removeTime}%"

And here is the result I got:

Results available at https://i.imgur.com/Vsnmcko.png

Skript clearly has nothing to be ashamed of with this result, it's a very good result!

Creating a benchark allows both to test the speed of the parser (and thus to keep the parser fast) BUT ALSO to locate possible bugs. Example: Skript is very fast with paper spigot 1.13 but is very slow with 1.15, this means there is something wrong with it.

Anyway, I think in my personal opinion that doing a benchmark can only be beneficial to the project.

Update

A better benchmark was created by @KingAlterIV, thanks to him: https://gist.github.com/KingAlterIV/d1c069b51ca683510391241093e3d5b7

tutur1004 commented 4 years ago

Try this with skript-db ^^ it's fun in async mode

Wealthyturtle commented 4 years ago

Personally not a fan of this either, I mean... this sorta falls under the users-side.

TheLimeGlass commented 4 years ago

Putting Skript into debug mode details times, and lots of information. Check your config.sk. It will also make addons error that don't properly handle debug messages.

TheLimeGlass commented 2 years ago

There is skript timings?

TheLimeGlass commented 1 year ago

Profiler has been added.