﻿$ClockResolutionScriptBlock = {
    Param ($OutFile)

    function Get-ClockRes {
  <#  
      This prints out the system timer clock resolution every 1 second to a CSV file
  #>  
  Param( 
    [parameter(Mandatory=$true)][string]$OutputFile
  )
      
  begin {
    $cd = [AppDomain]::CurrentDomain  
    $attr = 'AnsiClass, Class, Public, Sealed, BeforeFieldInit'  
      
    if (!($cd.GetAssemblies() | ? {  
      $_.FullName.Contains('NtClockRes')  
    })) {  
      $type = (($cd.DefineDynamicAssembly(  
        (New-Object Reflection.AssemblyName('NtClockRes')), [Reflection.Emit.AssemblyBuilderAccess]::Run  
      )).DefineDynamicModule('NtClockRes', $false)).DefineType('ClockRes', $attr)  
      [void]$type.DefinePInvokeMethod('NtQueryTimerResolution', 'ntdll.dll',  
        [Reflection.MethodAttributes]'Public, Static, PinvokeImpl',  
        [Reflection.CallingConventions]::Standard, [Int32],  
        @([Int32].MakeByRefType(), [Int32].MakeByRefType(), [Int32].MakeByRefType()),  
        [Runtime.InteropServices.CallingConvention]::Winapi, [Runtime.InteropServices.CharSet]::Auto  
      )  
      $global:clockres = $type.CreateType()  
    }  
  }  
  process {  
    [Int32]$max = $min = $cur = 0  
    if (($clockres::NtQueryTimerResolution([ref]$max, [ref]$min, [ref]$cur)) -ge 0) {  
      <#'Maximum timer interval: {0} ms' -f ($max / 10000)  
      'Minimum timer interval: {0} ms' -f ($min / 10000)  
      'Current timer interval: {0} ms' -f ($cur / 10000) #>

      $time = Get-date -format T
      $curTimerRes = ($cur / 10000)

      $time + ',' + $curTimerRes | Add-Content $OutputFile -Encoding Unicode
    }
    else { 'Could not get resolution of system clock' }  
  }
}
    if (!(Test-Path alias:clockres)) { Set-Alias clockres Get-ClockRes }    
    'Timestamp,TimerResolution' | Set-Content $OutFile -Encoding Unicode

    while ($true)
    {
        Start-Sleep -s 1
        Get-ClockRes($OutFile)
    }
    
}

Add-Type -TypeDefinition @"

   public enum PlaybackSourceEnum
   {
      YOUTUBE_DEFAULT = -8,
      YOUTUBE_CUSTOM,
      CUSTOM_STREAMING_AUDIO,
      DEFAULT_STREAMING_AUDIO,
      NETFLIX,
      DEFAULT_STREAMING_VIDEO,
      CUSTOM_STREAMING_VIDEO,
      CUSTOM_LOCAL_VIDEO,
      DEFAULT_LOCAL_AUTOSELECT
   }
"@


Add-Type -TypeDefinition @"

   public enum WorkloadEnum
   {
      MOVIESTV = 0,
      GROOVE,
      NETFLIX,
      YOUTUBE,
   }
"@

Add-Type -TypeDefinition @"

   public enum TraceOption
   {
      LIGHT = 1,
      VERBOSE,
   }
"@