[Idea] Benchmarking...

Discussions on various DOL development features

Moderator: Support Team

[Idea] Benchmarking...

Postby Leodagan » Sat Oct 25, 2014 10:41 am

While a lot of people may look for "best performance" for their shard...

And others may thought that some un-optimized part of DOL is grieving their player max count :)

I may have something interesting (still pretty much at proof of concept stage) for those who cares to PROVE that some code may run better and that rewriting some "working" parts is worth anything :)

This isn't something that I'll care to advance too much, but it could be useful for other contributors to have some way of testing their updates (pretty much like Unit Test, but honestly I have no Idea how Unit Test must be done...)

Actually I made an in-game command "/benchmark" that takes some arguments to target specific method pre-set in the command handler...

This is what helped me in to track memory leaks around some of my work :)

Actual Benchs are targeted at skills, and use the current "player" to have some "variables" to work with, it would be better if some data could be gathered from the server objects to have a "standalone" benchmark that could be run from console (without needing any player to be logged in)

So before I start anything more general-purpose, I would like to gather some hints about what part of the game should be tested ?

Player Movements ? Mobs AI ? Spell Handlers ? Living Fighting Rules ? Geometric/Range Methods ? Loot Generator ? Mob Death Spam :roll: ?

And About how to run these tests without causing any players harm (allowing to bench in-game to look for long-run misbehavior), maybe by using a Instance Region and trying to instantiate scripted GamePlayer...


Here is my actual class handling a few tests, not really usefull but it's my starting point :)
Code: Select all
using System; using System.Linq; using DOL.GS; using DOL.GS.PacketHandler; using DOL.Language; namespace DOL.GS.Commands { [CmdAttribute( "&benchmark", ePrivLevel.Admin, "Benchmark some aspects of DOL Server.", "/benchmark listskills|listspells|styles|respawns|deaths|tooltips")] public class BenchmarkCommand : AbstractCommandHandler, ICommandHandler { public void OnCommand(GameClient client, string[] args) { if (args.Length < 2 || client == null || client.Player == null) { DisplaySyntax(client); return; } long start,spent,largest; switch(args[1]) { case "hybrid": start = GameTimer.GetTickCount(); largest = 0; for (int i = 1000 ; i > 0 ; i--) { foreach (Specialization spec in client.Player.GetSpecList().Where(item => item.HybridSpellList)) { var tmp = spec.GetLinesSpellsForLiving(client.Player); if (tmp.Count > largest) largest = tmp.Count; } } spent = GameTimer.GetTickCount() - start; client.Player.Out.SendMessage(string.Format("Hybrid Benchmark took {0}ms for 1000 iterations... (Count: {1})", spent, largest), eChatType.CT_System, eChatLoc.CL_SystemWindow); break; case "listskills": start = GameTimer.GetTickCount(); largest = 0; for (int i = 1000 ; i > 0 ; i--) { var tmp = client.Player.GetAllUsableSkills(true); if (tmp.Count > largest) largest = tmp.Count; } spent = GameTimer.GetTickCount() - start; client.Player.Out.SendMessage(string.Format("Skills Benchmark took {0}ms for 1000 iterations... (Count: {1})", spent, largest), eChatType.CT_System, eChatLoc.CL_SystemWindow); break; case "listspells": start = GameTimer.GetTickCount(); largest = 0; for (int i = 1000 ; i > 0 ; i--) { var tmp = client.Player.GetAllUsableListSpells(true); if (tmp.Count > largest) largest = tmp.Count; } spent = GameTimer.GetTickCount() - start; client.Player.Out.SendMessage(string.Format("Spells Benchmark took {0}ms for 1000 iterations... (Count: {1})", spent, largest), eChatType.CT_System, eChatLoc.CL_SystemWindow); break; } } } }
If anyone feels like helping around this...

I'm not too comfortable with Reflection but the Benchmark Code could be targeted at Scripted Object too, trying to Instantiate Custom Quest/Mob/Other... and test the various methods available, this way the benchmark could slowly become a "Shard Self-Test" command !
User avatar
Leodagan
Developer
 
Posts: 1350
Joined: Tue May 01, 2012 9:30 am
Website: https://daoc.freyad.net
Location: Lyon

Re: [Idea] Benchmarking...

Postby Graveen » Sat Oct 25, 2014 4:18 pm

I have reviewed long time ago the unit tests, to allow debugging without launching the client. Well, i used it a bit, but it is finally limited. Good to explore an object such as GamePlayer, and troubleshoot loading skills etc..., but bad to ie process quest steps.
Image
* pm me to contribute in Dawn of Light: code, database *
User avatar
Graveen
Project Leader
 
Posts: 12660
Joined: Fri Oct 19, 2007 9:22 pm
Location: France

Re: [Idea] Benchmarking...

Postby Leodagan » Sun Oct 26, 2014 7:20 am

Well the troubles I see around unit test is that it's targeted to test some small part of code or object methods, where DOL have so much behavior based on tons of different objects and collections of these objects!

With the improvement of the data-driven behavior there is a lot of "Code" that is extracted from DB, beginning with object custom instances (SpellHandler, NPC Class, Region Class etc etc), or other flag value that totally change object behavior, so "Tests" may need to gather this data to have a real purpose (or use some pre-set of data that is meant to test a lot of uses cases...)

So the Benchmarking is an easier approach, it will use the actual state of a running DOL server to test given methods, but it's not the same purpose ;)
User avatar
Leodagan
Developer
 
Posts: 1350
Joined: Tue May 01, 2012 9:30 am
Website: https://daoc.freyad.net
Location: Lyon


Return to “%s” DOL Development Discussion

Who is online

Users browsing this forum: No registered users and 1 guest