forked from openai/codex
-
Notifications
You must be signed in to change notification settings - Fork 0
124 lines (101 loc) · 2.87 KB
/
Copy pathcpu-profiling.yml
File metadata and controls
124 lines (101 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: CPU Profiling
on:
push:
branches: [feature/cpu-optimization]
pull_request:
branches: [main]
jobs:
cpu-sampling:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Run CPU sampling test
run: |
python -c "
import sys
import time
sys.path.insert(0, 'harness/src')
from harness.cpu_profiler import CPUSampler, get_cpu_info
print('=== CPU Info ===')
info = get_cpu_info()
print(f'Cores: {info[\"physical_cores\"]} physical, {info[\"logical_cores\"]} logical')
print(f'Freq: {info[\"freq_mhz\"]} MHz')
print(f'Arch: {info[\"arch\"]}')
print('\\n=== CPU Sampling Test ===')
sampler = CPUSampler(interval=0.01)
# Simulate some CPU work
def cpu_work():
total = 0
for i in range(1000000):
total += i * i
return total
sampler.start()
for _ in range(5):
cpu_work()
time.sleep(0.2)
stats = sampler.stop()
print(f'Samples: {stats.get(\"samples\", 0)}')
print(f'CPU Avg: {stats.get(\"cpu_avg\", 0):.1f}%')
print(f'CPU Peak: {stats.get(\"cpu_peak\", 0):.1f}%')
print(f'Memory Avg: {stats.get(\"memory_avg\", 0):.1f}MB')
print(f'Memory Peak: {stats.get(\"memory_peak\", 0):.1f}MB')
print('CPU profiling working!')
"
async-runtime:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Test async runtime
run: |
python -c "
import sys
import asyncio
sys.path.insert(0, 'harness/src')
from harness.async_runtime import AsyncRuntime, gather_with_limit
async def dummy_task(n):
await asyncio.sleep(0.01)
return n * 2
print('=== Async Runtime Test ===')
runtime = AsyncRuntime()
# Test gather_with_limit
async def test_gather():
tasks = [dummy_task(i) for i in range(20)]
results = await gather_with_limit(*tasks, max_concurrent=5)
return results
results = runtime.run(test_gather())
print(f'Results: {len(results)} tasks completed')
print('Async runtime working!')
"
graceful-shutdown:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Test graceful shutdown
run: |
python -c "
import sys
sys.path.insert(0, 'harness/src')
from harness.shutdown import GracefulShutdown, register_cleanup, get_shutdown_state
print('=== Graceful Shutdown Test ===')
shutdown = GracefulShutdown()
cleanup_called = []
@shutdown.on_shutdown
def cleanup_handler():
cleanup_called.append(True)
shutdown.register()
state = get_shutdown_state()
print(f'Registered: {state.stage.value}')
print('Graceful shutdown working!')
"