General
  • Break up large scripts into multiple script files (alt+r > "File" > "New")
  • Put aliases that are used excessively at the top of the script file.
  • Put scripts with aliases that are used excessively at the top of the script order (alt+r > "File" > "Order")



Coding
  • Limit file read/writes 1
  • Limit event exposure by being as specific as possible with the event definition and break up large event bodies that handle multiple triggers into separate events 2
  • Group similar processing of multiple /timers together under a single timer; Avoid using the -h switch for timers when possible.
  • Limit various forms of scripted looping
  • Not all if-statement formats process at the same speed; pick accordingly
  • When using native commands or identifers use ! or ~ prefixing to bypass mIRC's custom alias lookup 3
  • 'if statements' are faster than '$iif()'s 4
  • If using $gettok on the same set of data multiple times look into using /tokenize and $n instead.



Notes
  1. Instead of using flat-files as a data storage look into Hash Tables(which are stored in memory; can be saved/loaded from file) or INI files(which are cached in memory after the first access). If you must use a flat file for a data-store look into using /filter /loadbuf or the File Handling commands & identifers(/fopen $fread /fclose) when accessing the file via a loop
  2. Dividing up events into separate triggers makes the processing faster, ensures your code is module, and makes your code more human-readable
  3. For instances where you wish to use a native command prefix the command with "!", and for native identifers insert a "~" after the $:
    Code:
    !echo -a $~me
  4. Bench marks for if vs $iif:
    Click to reveal..
    Code:
    iterations: 1000000
    if vs $iif: 50.36s vs 81.234s


    Code:
    alias -l bench1 {
      if ($1) return $true
      return $false
    }
    alias -l bench2 {
      return $iif($1, $true, $false)
    }
    
    alias bench_1 {
      !var %x $1
      !var %z $~ticks
      while (%x) {
        !noop $bench1(0)
        !noop $bench1(1)
        !dec %x
      }
      !return $~calc($~ticks - %z)
    }
    alias bench_2 {
      !var %x $1
      !var %z $~ticks
      while (%x) {
        !noop $bench2(0)
        !noop $bench2(1)
        !dec %x
      }
      !return $~calc($~ticks - %z)
    }
    alias benchit {
      var %a = $bench_1($1)
      var %b = $bench_2($1)
    
      echo -a iterations: $1
      echo -a if vs $!iif: $calc(%a / 1000) $+ s vs $calc(%b / 1000) $+ s
    }