Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"python.testing.unittestArgs": [
"-v",
"-s",
"C:/sources/LLMLingua/tests",
"-p",
"test*.py"
],
"python.testing.pytestEnabled": false,
"python.testing.unittestEnabled": true,
"python.testing.unittestDiscoveryAdapter": "legacy",
"python.testing.autoTestDiscoverOnSaveEnabled": true
}
1 change: 1 addition & 0 deletions llmlingua/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

# flake8: noqa
from .prompt_compressor import PromptCompressor
from .prompt_compress_multicore import PromptCompressorV2
from .version import VERSION as __version__

__all__ = ["PromptCompressor"]
16 changes: 16 additions & 0 deletions llmlingua/monitor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import psutil
import time

# Get the current process
process = psutil.Process()

while True:
# Get the process's overall CPU usage as a percentage of total system CPUs
cpu_usage = process.cpu_percent(interval=1)

# Get per-core CPU usage
per_core_usage = psutil.cpu_percent(interval=None, percpu=True)

print(f"Process CPU usage: {cpu_usage}%")
print(f"Per-core CPU usage: {per_core_usage}")
time.sleep(1)
2,469 changes: 2,469 additions & 0 deletions llmlingua/prompt_compress_multicore.py

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions script/monitor_cores.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
while ($true) {

# Get the load percentage for each CPU core
$cpuLoad = Get-Counter '\Processor(*)\% Processor Time'

# Display the load percentage for each core
$cpuLoad.CounterSamples | ForEach-Object {
$core = $_.InstanceName
$load = $_.CookedValue
Write-Output "Core ${core}: ${load}% load"
# Get the process information
$processes = Get-Process | Sort-Object CPU -Descending | Select-Object -First 1

# Display the top process information
$processes | ForEach-Object {
$id = $_.Id
$name = $_.Name
$cpu = $_.CPU
Write-Output "Top Process ID: $id, Name: $name, CPU Time: $cpu"
}

}


Start-Sleep -Milliseconds 500
Clear-Host
}
20 changes: 20 additions & 0 deletions script/process_on_cores.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Get the load percentage for each CPU core
$cpuLoad = Get-Counter '\Processor(*)\% Processor Time'

# Display the load percentage for each core
$cpuLoad.CounterSamples | ForEach-Object {
$core = $_.InstanceName
$load = $_.CookedValue
Write-Output "Core ${core}: ${load}% load"
}

# Get the process information
$processes = Get-Process | Select-Object Id, Name, CPU

# Display the process information
$processes | ForEach-Object {
$id = $_.Id
$name = $_.Name
$cpu = $_.CPU
Write-Output "Process ID: $id, Name: $name, CPU Time: $cpu"
}
192 changes: 192 additions & 0 deletions tests/test_llmlingua2_multicore.py

Large diffs are not rendered by default.