1. Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Other Use YAML (Responsibly)

Discussion in 'Tutorials' started by Orendigo, Jul 19, 2017.

  1. Orendigo

    Orendigo Well-Known Member

    Joined:
    Feb 23, 2017
    Messages:
    127
    Likes Received:
    15
    So I posted this in a thread a while ago, and I felt it needs a bigger audience, so I'll post it here.

    So, I was curious about the subject, so I ran a few test to gather data. My findings were pretty much what I expected after reading Rezz's Don't Use Yaml post.

    Using the script provided in the post mentioned, I gathered data; here are my findings:

    YAML vs. Skript Variable Setting (Unmodified Script)
    [​IMG]
    YAML vs. Skript Variable (Unmodified Script)
    [​IMG]
    *Amount if time: in seconds; not ticks!

    Data (Unmodified Script)

    [​IMG]

    I decided to see if using an SQlite database would change anything; it did not, so I decided not to include it in the graphs.

    While it makes sense for Skript's Setting Data to slightly increase (but never strays too far from 1 second), Skript's Getting Data seems to be skewed. This is because of the "Pause" feature used in the testing script, which prevents the server from crashing during YAML getting/setting with large values.

    The values themselves are skewed, the smaller elements increments only give a better visualization as to how skewed; however, this data skewness is necessary, as without it, gathering this data would crash the server.

    To get a better insight on how the data is being skewed, I decided to remove the "pause" buffer in order to get better values, knowing full-well that my server crash after a point- and it did:

    Data (Modified Script)
    [​IMG]

    I was only able to get to 100 Elements without the YAML data being skewed. I believe better numbers can be achieved using the $ thread expression to prevent crashing, but further testing would need to be done. While these numbers provide interesting insight, I will not be using these values to draw a conclusion, as they are incomplete.

    Results:
    For setting data, the difference in efficiency starts to become ever so slightly apparent near the 100 elements mark, and is further amplified with 250 elements and beyond, as the YAML time is nearly +50% of Skript Variables time. When it comes to getting data, the difference is rather similar; the difference in efficiency becomes notable between the 100 elements mark, and the 250 elements mark.

    Conclusion:
    With current addons, YAML data seems to increase exponentially (which supports Rezz's claim of addons needing to read every value). In addition, Skript's Variables are pretty darn efficient, which makes sense.

    However, I do not believe this "local ban of YAML until someone makes an efficient addon" mentality is necessary. I'm not saying YAML is the full way to go- if you use it responsibly, you shouldn't see a problem.

    Things you can probably use YAML for without noticing a significant difference in data storage timings:
    • Setting data that doesn't change often (or at all)
    • Getting specific values from config files (either script configs, or plugin configs)
    • Not making giant list of random values in a consecutive manner
    Are we able to create/modify json files yet? Is that a thing?
     
    • Like Like x 1
  2. ShaneBee

    Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,172
    Likes Received:
    190
    Json has been possible for awhile with skutils and skript-json
     
  3. ShaneBee

    Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,172
    Likes Received:
    190
    :O

    I'll have to see how well those implementations size-up to Skript's variables!
     
  4. ShaneBee

    Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,172
    Likes Received:
    190
    Skript's variables are loaded completely into memory when the server starts. Variables are saved immediately to memory and saved to the disk asynchronously to avoid blocking the main thread.

    Because of this behavior, Skript's variables will always be faster than any solution that simply reads from/writes to the disk.
     
Loading...