rawcpu/docs/quickstart.md
2026-07-19 23:29:46 +05:00

48 lines
968 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# quickstart
## установка
```
pip install rawcpu
```
## узнать процессор
```python
import rawcpu
print(rawcpu.vendor()) # GenuineIntel / AuthenticAMD
print(rawcpu.brand()) # полная строка модели
```
## проверить фичи перед SIMD-кодом
```python
if rawcpu.has_feature("avx2"):
# можно грузить AVX2-путь
...
else:
# fallback
...
```
список доступных имён — `rawcpu.FEATURES`.
## точный замер тактов
`time.perf_counter()` меряет время через ОС, `rdtsc()` — реальные такты процессора напрямую:
```python
start = rawcpu.rdtsc()
do_something()
end = rawcpu.rdtsc()
print(end - start, "cycles")
```
## сырой cpuid
```python
eax, ebx, ecx, edx = rawcpu.cpuid(leaf=7, subleaf=0)
```
leaf/subleaf — как в интеловской документации по CPUID.