# encoding: ascii
# api: powershell
# title: Hash efficiency example
# description: TLDR:  $hash.$name = $value is stupidly inefficient.
# version: 0.1
# author: BattleChicken
# license: CC0
# x-poshcode-id: 6283
# x-archived: 2016-11-18T17:09:26
# x-published: 2016-04-06T23:04:00
#
#
$rng = 10000
(Measure-Command {
    $hash = @{}
    foreach ($a in 1..$rng){
        $hash[$a] = $a
    }
}).totalmilliseconds

(Measure-Command {
    $hash = @{}
    foreach ($a in 1..$rng){
        $hash.$a = $a
    }
}).TotalMilliseconds

(Measure-Command {
    $hash = @{}
    foreach ($a in 1..$rng){
        $hash.add($a, $a)
    }
}).TotalMilliseconds
