Advertisement
smeech

Speed test between shell: and script

Jun 22nd, 2024 (edited)
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.13 KB | None | 0 0
  1. # Espanso speed test between shell: and script
  2. # No discernible difference here on Linux, but recommend using script: to avoid calling
  3. # an unnecessary process
  4. # Conversation at https://discord.com/channels/884163483409731584/1013916990760554608/1253033704599846973
  5.  
  6. global_vars:
  7.   - name: code
  8.     type: echo
  9.     params:
  10.       echo: |
  11.        $startTime = Get-Date
  12.         $processes = Get-Process
  13.         for ($i = 1; $i -le 1000; $i++) {
  14.           $sortedProcesses = $processes | Sort-Object -Property CPU -Descending
  15.         }
  16.         $endTime = Get-Date
  17.         $totalTime = New-TimeSpan -Start $startTime -End $endTime
  18.         Write-Output "Total execution time: $($totalTime.Hours) hours, $($totalTime.Minutes) minutes, $($totalTime.Seconds) seconds."
  19.  
  20. matches:
  21.   - trigger: :test1
  22.     replace: "{{output}}"
  23.     vars:
  24.       - name: output
  25.         type: shell
  26.         params:
  27.           shell: pwsh
  28.           cmd: "{{code}}"
  29.  
  30.   - trigger: :test2
  31.     replace: "{{output}}"
  32.     vars:
  33.       - name: output
  34.         type: script
  35.         params:
  36.           args:
  37.            - pwsh
  38.             - -c
  39.             - "{{code}} "
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement