Author Topic: Journal Functions (Performance)  (Read 7978 times)

0 Members and 1 Guest are viewing this topic.

Offline unisharpTopic starter

  • Elite
  • ***
  • *
  • Posts: 196
  • Activity:
    0%
  • Reputation Power: 4
  • unisharp has no influence.
  • Gender: Male
  • Respect: +40
  • Referrals: 0
    • View Profile
Journal Functions (Performance)
« on: April 02, 2015, 06:43:26 AM »
0
So I'm analyzing reports on my application and I'm using an average process time of 3.6% which really ain't bad at all, but I'm going to be running multiple applications so I want to optimize as much as possible.

What does my bandage function do?  It's started in a new thread, once it's called it'll bandage the person then wait for completion.  When it completes it sets a boolean to false and the thread exits.  Next time a bandage check is made it checks the boolean before running the bandage function.

Here's the function I'm analyzing...

Code: [Select]
static void bandage(Creature HealTarget)
{
if (HealTarget.Distance < 2 && bandages != null)
{
bandaging = true;
bandages.Use();
Stealth.Default.WaitTargetObject(HealTarget.ID);
response("using bandage on " + HealTarget.Name + ".");
Stealth.Default.WaitJournalLine(DateTime.Now, "You finish applying the bandages|You apply the bandages, but they barely help|You heal what little damage your patient had|You did not stay close enough to heal your patient|That is too far away", 15000);
}
bandaging = false;
}



Digging into -> Combot.Routine.Main

Over half the processing time used in the main routine is checking for health, which is understandable.

Digging into ->Combat.Heal.checkHealth

There's only one called function in this path and it's Bandage.  We can see that WaitJournalLine is using up the most processing time in this function which is also understandable.  Digging into WaitJournalLine, I can see that it's using InJournalBetweenTimes.

Just looking for some suggestions from you guys, I don't have much experience with ScriptDotNet2.dll and documentation is outdated.  Wasn't sure if anyone knew of a better way to do this :)  Basically 30% of the application processing time is spent checking the Journal and I'd like to reduce that.

Thanks!
« Last Edit: April 02, 2015, 06:48:02 AM by sibble »

Offline dxrom

  • Master of the milestones!
  • Elite
  • *
  • *
  • Posts: 1080
  • Activity:
    0%
  • Reputation Power: 15
  • dxrom is working their way up.dxrom is working their way up.dxrom is working their way up.
  • KEYBOARD COWBOY, GREAT SAMURAI OF THE INTERNET.
  • Respect: +100
  • Referrals: 1
    • View Profile
Re: Journal Functions (Performance)
« Reply #1 on: April 02, 2015, 09:20:22 AM »
0
For bandages, you could snap shot your stamina at the time of applying a bandage and then use the healing time formula to calculate the timer, which can be affected by being hit. Or you could also use evBuff_DebuffSystem and play off the healing buff icon.



 ​_██​_
(ಠ​_ృ)
I do say, ol' Chap! Come play EVE Online! Why here is a 21 Day Free Trial!

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13301
  • Activity:
    0%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Journal Functions (Performance)
« Reply #2 on: April 02, 2015, 09:40:44 AM »
0
Can journal additions be made to fire off events?  If so then you could just have a journal event handler there to service the interrupt and go back later to analyze.
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline Crome969

  • Moderator
  • *
  • *****
  • Posts: 2098
  • Activity:
    0%
  • Reputation Power: 25
  • Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.
  • Gender: Male
  • UO Enthusiast
  • Respect: +211
  • Referrals: 10
    • View Profile
    • ScriptSDK
Re: Journal Functions (Performance)
« Reply #3 on: April 02, 2015, 10:27:55 AM »
0
For bandages, you could snap shot your stamina at the time of applying a bandage and then use the healing time formula to calculate the timer, which can be affected by being hit. Or you could also use evBuff_DebuffSystem and play off the healing buff icon.

I would also toy by events :

evBuff_DebuffSystem : [ID : Cardinal, Attribute_ID : Word, IsEnabled : Boolean] - A (de)buff is (de)activated

this by far gives u the best way to observe healing. The Icon appear on heal and disapear when done. On both times this event gets fired.

You also could try the Events for Clilocs\messages but healing would be the best way.

Offline unisharpTopic starter

  • Elite
  • ***
  • *
  • Posts: 196
  • Activity:
    0%
  • Reputation Power: 4
  • unisharp has no influence.
  • Gender: Male
  • Respect: +40
  • Referrals: 0
    • View Profile
Re: Journal Functions (Performance)
« Reply #4 on: April 02, 2015, 02:00:57 PM »
0
I switched to using the BuffDebuff system, there's a couple things I ran into.

#1 the .IsEnabled is always off

When I use a bandage on someone, these are the BuffDebuff events:

-bandage starts
1069 off
1069 off

- bandage finishes
1069 off
1101 off

I'm assuming the 1101 is an indication of when bandaging has finished.  I used that to determine if bandaging is true or false.

#2 Tested with 1 bot and it worked fine.  Tested with 3 bots and I get an issue, sometimes it won't catch the 1101.  Why do you think when 3 bots are running that the 1101 event doesn't catch sometimes?  Am I flooding with requests?

What I did for now was make a date time check and if bandaging has been true for over 8 seconds (maximum bandage time) then it'll turn false.

What's the most profiles you guys have ran simultaneously (while using scripts on each profile)?

Offline Crome969

  • Moderator
  • *
  • *****
  • Posts: 2098
  • Activity:
    0%
  • Reputation Power: 25
  • Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.
  • Gender: Male
  • UO Enthusiast
  • Respect: +211
  • Referrals: 10
    • View Profile
    • ScriptSDK
Re: Journal Functions (Performance)
« Reply #5 on: April 02, 2015, 03:05:54 PM »
0
Since i work on RebirthUO as Dev i hadnt much time anymore to toy deeper with stealth.
However on my Prime Time as Scripter (i was using pascal back then) i had days where i ranned up to 30 accounts on up to 15 different shards...

The IsEnabled seems to be an old bug i once reported (but forgot to check myself then on source) its like i check if value is false or !false then it works. but if you check for true it never occur.

Rebirth keeps me busy, else i would load up the source and look about..




Offline unisharpTopic starter

  • Elite
  • ***
  • *
  • Posts: 196
  • Activity:
    0%
  • Reputation Power: 4
  • unisharp has no influence.
  • Gender: Male
  • Respect: +40
  • Referrals: 0
    • View Profile
Re: Journal Functions (Performance)
« Reply #6 on: April 03, 2015, 07:48:14 AM »
0
i had days where i ranned up to 30 accounts on up to 15 different shards..



LOL I'm gona have to do a lot more optimizing to get to that!
« Last Edit: April 03, 2015, 07:50:19 AM by sibble »

Offline Boydon

  • Moderator
  • **
  • *****
  • Posts: 76
  • Activity:
    0%
  • Reputation Power: 3
  • Boydon has no influence.
  • Respect: +16
  • Referrals: 0
    • View Profile
Re: Journal Functions (Performance)
« Reply #7 on: April 16, 2015, 01:35:03 PM »
0
evBuff_DebuffSystem only works on the player mobile (on Self() just to be be even more clear).

I've just checked the logic once again and it is correct (below you have an extract of it from stealth src), so you get what the server is sending you.

Anyway next version of Stealth will have new functionality for the buffbar (I know this is a teaser :D):
Code: [Select]
function GetBuffBarInfo : TBuffBarInfo

TBuffBarInfo = packed record
  Count : Byte;
  Buffs : array of TBuffIcon;
end;

TBuffIcon = packed record
  Attribute_ID : Word;
  TimeStart : TDateTime;
  Seconds : Word;
  ClilocID1 : Cardinal;
  ClilocID2 : Cardinal;
end;

And this is how the evBuff_DebuffSystem is triggered:

Code: [Select]
function TCharacter.GetInfoFromPacket_0xDF(PacketObj: PBArray;
  PacketLen: Integer): Boolean;
var
  Attribute_ID: Word;
  ObjectInfo: PObjectInfo;
  ID: Cardinal;
  IsEnabled: Boolean;
 
begin
  Result := True;
  ID := PacketReader.ReadDword;
  if ID <> PlayerID then
    Exit;

  Attribute_ID := PacketReader.ReadWord;

  //really format change here. Before this was Enabled flag, now
  //it's Items Count. But no matter.
  IsEnabled := WordBool(PacketReader.ReadWord);

  if Attribute_ID < 1000 then // 0x3E8 = 1000
    Exit;

  fObjects.LockObjects;
  New(ObjectInfo);
  if not fObjects.GetObjectInfo(ID, ObjectInfo) then
  begin
    Dispose(ObjectInfo);
    fObjects.UnLockObjects;
    Exit;
  end;

  case Attribute_ID of
    1037:
      if IsEnabled then
        ObjectInfo^._MobileFlag := ObjectInfo^._MobileFlag or $20
      else
      if (ObjectInfo^._MobileFlag and $20) = $20 then
        ObjectInfo^._MobileFlag := ObjectInfo^._MobileFlag - $20;// paralyze

    1038:
    begin // poison
      ObjectInfo^._Poisoned := IsEnabled;
      SetPoisonedStatus(IsEnabled);
    end;
  end;
  fObjects.AddObject(ObjectInfo);
  fObjects.UnLockObjects;

  TryExecEventHandler(evBuff_DebuffSystem,[ID,Attribute_ID, IsEnabled]);

  end;
end;
Member of the Stealth development team.

Tags: