mIRC Performance Test
#1

Hi!

My first topic on this forum, parteh!

Anyhow, I've got a question. And haters gonna hate. I'm quite into mIRC scripting, but I'd like to test my scripts on performance. Though, up till now, I didn't find any way to do so.

The first problem I encountered is: how can you get the amount of passed time in millisecond on mIRC? Looking at the "Time and Date Identifiers" help, I did not find anything which returns that. As an attempt to still accurately count time, I chose to count in ticks. There's an algorythm to convert ticks into ms, but I don't know how.

Second problem I found out: how to run this without actually echo'ing what the command does? If you want to test a command which sends a message to the server, you just can't (using my method). It'd spam your command 1000 times if you want it to test with that amount. You could fix this by adding a ";" in front of every echo line. But then, the performance test won't be accurate again, as you're skipping some of the commands. That won't do any harm to normal display messages, but if you make a calculation within your echo, it will have an effect on performance.

Third, and main problem: how to count the time passed. Using a timer, it won't work. I already tested this script:

Код:
/performance {
  if ($1 isnum) {
    if ($2) {
      set %start.tmp $ticks
      .timer $1 0 $2-
      set %stop.tmp $ticks
      echo 2 -at Passed time to run " $+ $2- $+ " $1 times: $calc(%stop.tmp - %start.tmp)
      unset %start.tmp
      unset %stop.tmp
    }
    else {
      echo 4 -at ERROR: 1Specify a command
    }
  }
  else {
    echo 4 -at ERROR: 1Specify an amount of loops
  }
}
But that just doesn't want to do the trick. It sets the start to a specific amount of ticks, starts the timer and then immediately (without any command being executed) sets the stop of the ticks. Causing to return 0 in any cause.

Yet again, I found a fix to this: using a while loop. That way the code executes before the timer is unset. So this is the code I'm working further on:

Код:
/performance {
;Syntax: /performance <amount of seconds> <command> <parameters>
  if ($1 isnum) {
    if ($2) {
    ;twice an error check: syntax must be right
      set %start.tmp $ticks
      ;sets the starting time in ticks
      var %i = 1
      while (%i <= $1) {
        $2-
        inc %i
      }
      ;loops the command a specific amount of times
      set %stop.tmp $ticks
      ;sets the stop time in ticks
      echo 2 -at Passed time to run " $+ $2- $+ " $1 times: $calc(%stop.tmp - %start.tmp)
      ;echoes the amount of time passed in ticks.
      unset %start.tmp
      unset %stop.tmp
      ;clears the variables used. I know I could use "var %start = $ticks", but I dislike the usage of that. it's easier to debug when using globals in mIRC, except for loops
    }
    else {
      echo 4 -at ERROR: 1Specify a command
    }
  }
  else {
    echo 4 -at ERROR: 1Specify an amount of loops
  }
}
This command does work, but it's not accurate. As soon as there's one error, it stops running, due to the while loop.

Why errors? Again, because of the second problem. As soon as you try to echo something without being connected to a server (to prevent flooding), it sends you the error "not connected to server". And thus stops. The fix of the problem is to stop the echo'ing, as said before, but then the complete command becomes inaccurate. I tested performance of a command which mainly uses echo'ing, and it returns 62 ticks on 1000 runtimes! That's far less than a ms.

So my questions are:
  • How to convert ticks in ms: Found this on ******: Milliseconds = CPYU_ticks*clock_rate*1000 and Milliseconds = ticks/10000. Which one is right? If it's the first, how to find my clock rate (I'm not good with hardware)
  • IMPORTANT How to run without echo'ing everything: I don't even think there's a fix for this. "On *:INPUT:" doesn't trigger when you're not typing yourself
Anyone able to help me? Don't hate on mIRC, it's limited but still a good language to learn the basics of scripting!

Pastebin link, with fancy colours: http://pastebin.com/8cB4VnLH

Kind regards
-[MM]IKKE
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)