title: is there a way to make powershell script sleep in nano seconds?
body: <p>I am using the following PowerShell script to generate events and simulate different system loads. When <code>$sleepIntervalInMilliSeconds=0</code>, CPU usage is 100%. </p>
  
  <p>Then the CPU usage is similar (56%) for any value of <code>$sleepIntervalInMilliSeconds &gt;= 1</code>. </p>
  
  <p>I think the script needs to sleep in the magnitude of nanoseconds instead of milliseconds so that I can control CPU load to be 70%, 80% 90%. </p>
  
  <p>Is there a way to do this? A float number &lt; 1 seems not work. Appreciate any clue.</p>
  
  <pre><code>Param(
    [int]$sleepIntervalInMilliSeconds = 0
  )
  
  $eventGenScript = {
    $logName = "TestLog"
    $sourceName = "TestSource"
  
    while($true) {
      Write-EventLog -LogName $logName -Source $sourceName -Message "perfLog" -EventId 0 -EntryType information
      Start-Sleep -Milliseconds $using:sleepIntervalInMilliSeconds
    }
  }
  
  $threadCount = 2
  
  for($i=0; $i -lt $threadCount; $i++)
  {
    Start-Job $eventGenScript  
  }
  
  read-host "type a key to exit."
  </code></pre>