Anyone want to do some benchmark tests against Fanciful for me?

Status
This thread has been locked.

Justis

Community Member
Management
Feedback score
61
Posts
2,117
Reactions
2,414
Resources
0
A while ago I made this single class file API for sending JSON chat messages to replace the entire fanciful library.
Why did I do this? Because the fanciful library is massive and contains too many classes and far too many unnecessary methods that it requires its user utilize in order to style their messages. It makes for an unnecessarily verbose block of code just to send a nice message.
Same with Spigot's built in stuff. Far too many class names to memorize and steps involved in sending a message.



With mine:
Code:
new JsonMessage().append(ChatColor.RED + "Hey there! " + ChatColor.BLUE + "I actually support chat colors without needing you to append a whole new string and use any special .color() or .stylize() methods!").setHoverAsTooltip("Line1", "Line2", ChatColor.RED + "Simple!").setClickAsExecuteCmd("/fly").save().send(player);

I recently gave it a long overdue update. Currently only available at that gist I've just linked.

The whole point was to make it easier to use, and I feel I've succeeded at that. However, I'm thinking it's probably faster than the fanciful library as well.

If anyone would like to give both libraries a shot. Take some benchmarks for short or long, simple or complex messages, please do and let me know the results.

I would but... My dedication to not using the fanciful library is beyond reason or negotiation it seems.
 
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

Justis

Community Member
Management
Feedback score
61
Posts
2,117
Reactions
2,414
Resources
0
Hey Justis, just saw this thread now, don't really go on MCM much anymore or post all too often. But I decided to give this a shot. I did this in a timespan of 10 minutes so hopefully this is accurate.

Here are my results:
rk3x7Rc.png


I ran it with the test case in the following Fanciful example method: https://github.com/mkremins/fanciful/blob/master/src/example/java/mkremins/fanciful/Example.java#L47
with your JSONMessage class and Fanciful.

I also used the other two example methods for all three classes; however, I like the results for the last example method.

Now you might be wondering, what's JSONSBMessage?
It's literally just the JsonMessage#save() method but with a StringBuilder, not much too it. But since you were using the shorthand += operator inside of a for-loop on a String, what happens behind the scenes is it pretty much generates a new StringBuilder class every time you use the shorthand concatenation; or any time you concatenate a string inside of a for-loop. I'm sure you knew this, just didn't realize what you were doing.

Overall, your API is way faster than Fanciful with just a few tests. So nice API. Way easier to use than Fanciful.

If I had more time, I would compare it against https://github.com/KyoriPowered/text. Apparently that's the new API everyone seems to be moving onto from Fanciful.

I just realized, I have your Json API as one of my utils in my projects, https://github.com/HuliPvP/Celestia...ipvp/celestial/util/api/chat/JsonMessage.java. I'm such a hypocrite, don't even have the StringBuilder in the save method. :(

EDIT: I don't have the StringBuilder in the project's JsonMessage class because it's not using for-loop concatenation. :p
Firstly, thank you so much for this.

I figured nobody was interested in doing this, so I didn't update the API on github.
I'd done some testing of my rushed update and realized I could shave off the redundant events within the extra data, since extra data will inherit the event settings of the parent text. I've updated the link just now with those changes.

Also, thank you for pointing out my lack of string appending optimization. Using += is just such a bad habit of mine at this point. I've been trying to break it for years.
"I'll get to optimizing that later". :p

Also, that github you linked me where you're using my JsonMessage api, you're using a very old version which doesn't utilize the "color" field for coloring. It simply uses the chat colors directly. Meaning that if the message you send forms a new line on the player client, the color will break, and the new line will be plain white text.
Do update to the latest version to resolve this.
 
Status
This thread has been locked.
Top