libretro.api.perf¶
Performance counter and SIMD feature detection types.
Corresponds to retro_perf_callback, retro_perf_counter,
and the RETRO_SIMD_* constants in libretro.h.
See also
PerfDriverThe
Protocolthat uses these types to expose performance counting functionality to theCore.libretro.drivers.perflibretro.py’s included
PerfDriverimplementations.
Module Attributes
A performance counter tick value. |
|
A timestamp in microseconds. |
|
Return the current system time in microseconds. |
|
Return the number of ticks elapsed since some unspecified epoch. |
|
Return a bitmask of detected CPU features. |
|
Log or display the state of every registered performance counter. |
|
Register a performance counter with the frontend. |
|
Start timing a registered performance counter. |
|
Stop timing a registered performance counter. |
Classes
SIMD instruction set flags reported by the host CPU. |
|
Provides functions for performance profiling and CPU feature detection. |
|
A named performance counter for profiling hot code paths within a |
- class CpuFeatures[source]¶
Bases:
IntFlagSIMD instruction set flags reported by the host CPU.
Corresponds to the
RETRO_SIMD_*constants inlibretro.h.>>> from libretro.api import CpuFeatures >>> CpuFeatures.SSE <CpuFeatures.SSE: 1>
- SSE = 1¶
- SSE2 = 2¶
- VMX = 4¶
- VMX128 = 8¶
- AVX = 16¶
- NEON = 32¶
- SSE3 = 64¶
- SSSE3 = 128¶
- MMX = 256¶
- MMXEXT = 512¶
- SSE4 = 1024¶
- SSE42 = 2048¶
- AVX2 = 4096¶
- VFPU = 8192¶
- PS = 16384¶
- AES = 32768¶
- VFPV3 = 65536¶
- VFPV4 = 131072¶
- POPCNT = 262144¶
- MOVBE = 524288¶
- CMOV = 1048576¶
- ASIMD = 2097152¶
- __new__(value)¶
- other in self¶
Returns True if self has at least the same flags set as other.
- iter(self)¶
Returns flags in definition order.
- len(self)¶
Return the number of members (no aliases)
- classmethod self[name]¶
Return the member matching name.
- __init__()¶
- class retro_perf_counter[source]¶
Bases:
StructureA named performance counter for profiling hot code paths within a
Core.Corresponds to
retro_perf_counterinlibretro.h.>>> from libretro.api import retro_perf_counter >>> c = retro_perf_counter() >>> c.registered False
- ident¶
Human-readable identifier for this counter.
- start¶
Tick value at the most recent start of measurement.
- total¶
Total accumulated ticks for this counter.
- call_cnt¶
Number of times this counter has been started.
- registered¶
Whether this counter has been registered with the frontend.
- __deepcopy__(_)[source]¶
Return a deep copy of this object, including all strings. Intended for use with
copy.deepcopy().
- __init__(*args, **kwargs)¶
- classmethod __new__(*args, **kwargs)¶
- retro_perf_get_time_usec_t¶
Return the current system time in microseconds.
Registered by the frontend and called by the core. The frontend should use the most accurate timer available on the platform.
- Returns:
The current time, in microseconds.
Corresponds to
retro_perf_get_time_usec_tinlibretro.h.
- retro_perf_get_counter_t¶
Return the number of ticks elapsed since some unspecified epoch.
Registered by the frontend and called by the core. The exact meaning of a tick depends on the platform (typically nanoseconds or CPU cycles).
- Returns:
The current tick count.
Corresponds to
retro_perf_get_counter_tinlibretro.h.
- retro_get_cpu_features_t¶
Return a bitmask of detected CPU features.
Registered by the frontend and called by the core to dispatch CPU-specific code paths at runtime.
- Returns:
A bitmask of
CpuFeaturesflags.
Corresponds to
retro_get_cpu_features_tinlibretro.h.
- retro_perf_log_t¶
Log or display the state of every registered performance counter.
Registered by the frontend and called by the core. The exact presentation is up to the frontend.
Corresponds to
retro_perf_log_tinlibretro.h.
- retro_perf_register_t¶
Register a performance counter with the frontend.
Registered by the frontend and called by the core once per counter, before the counter is started or stopped.
- Parameters:
counter – Pointer to a
retro_perf_counterto register. Itsidentfield must be set; all other fields must be zero orFalse.
Corresponds to
retro_perf_register_tinlibretro.h.
- retro_perf_start_t¶
Start timing a registered performance counter.
Registered by the frontend and called by the core right before the code being measured.
- Parameters:
counter – Pointer to a
retro_perf_counterthat has been registered withretro_perf_register_t.
Corresponds to
retro_perf_start_tinlibretro.h.
- retro_perf_stop_t¶
Stop timing a registered performance counter.
Registered by the frontend and called by the core right after the code being measured; the elapsed time is added to the counter’s
total.- Parameters:
counter – Pointer to the same
retro_perf_counterthat was previously passed toretro_perf_start_t.
Corresponds to
retro_perf_stop_tinlibretro.h.
- class retro_perf_callback[source]¶
Bases:
StructureProvides functions for performance profiling and CPU feature detection.
Corresponds to
retro_perf_callbackinlibretro.h.- __init__(*args, **kwargs)¶
- classmethod __new__(*args, **kwargs)¶
- get_time_usec¶
Returns the current time in microseconds.
- get_cpu_features¶
Returns a bitmask of
CpuFeatures.
- get_perf_counter¶
Returns the current performance counter tick value.
- perf_register¶
Registers a performance counter.
- perf_start¶
Starts a performance counter.
- perf_stop¶
Stops a performance counter.
- perf_log¶
Logs all registered performance counters.
- __deepcopy__(_)[source]¶
Return a deep copy of this object. Intended for use with
copy.deepcopy().>>> import copy >>> from libretro.api import retro_perf_callback >>> copy.deepcopy(retro_perf_callback()).get_time_usec is None True
- retro_time_t¶
A timestamp in microseconds.
- retro_perf_tick_t¶
A performance counter tick value.