Cache Performance Model
This project provides a model for simulating cache performance, including different cache configurations and replacement policies.
pip install cache-performance-model
Classes
Cache
Cache is an abstract base class for different cache models. It provides common functionality and properties for cache simulation.
DirectMappedCache
DirectMappedCache is a class for simulating a direct-mapped cache. It inherits from Cache and implements the read and write methods.
SetAssociativeCache
SetAssociativeCache is a class for simulating a set-associative cache. It inherits from Cache and implements the read and write methods. It supports different replacement policies such as RANDOM, FIFO, LRU, NMRU, and PLRU.
FullyAssociativeCache
FullyAssociativeCache is a class for simulating a fully associative cache. It inherits from Cache and implements the read and write methods. It supports different replacement policies such as RANDOM, FIFO, LRU, NMRU, and PLRU.
Examples
Direct Mapped Cache
from cache_performance_model.cache_model import DirectMappedCache
# Create a direct-mapped cache instance
cache = DirectMappedCache(cache_line_bytes=64, cache_size_kib=4)
# Perform read and write operations
cache.read(0x1A2B3C4D)
cache.write(0x1A2B3C4D)
# Print cache statistics
cache.stats()
Set Associative Cache
from cache_performance_model.cache_model import SetAssociativeCache
from cache_performance_model.types import ReplacementPolicy
# Create a set-associative cache instance with LRU replacement policy
cache = SetAssociativeCache(cache_line_bytes=64, cache_size_kib=4, n_way=4, replacement_policy=ReplacementPolicy.LRU)
# Perform read and write operations
cache.read(0x1A2B3C4D)
cache.write(0x1A2B3C4D)
# Print cache statistics
cache.stats()
Fully Associative Cache
from cache_performance_model.cache_model import FullyAssociativeCache
from cache_performance_model.types import ReplacementPolicy
# Create a fully associative cache instance with RANDOM replacement policy
cache = FullyAssociativeCache(cache_line_bytes=64, cache_size_kib=4, replacement_policy=ReplacementPolicy.RANDOM)
# Perform read and write operations
cache.read(0x1A2B3C4D)
cache.write(0x1A2B3C4D)
# Print cache statistics
cache.stats()
Installation
To install the required dependencies, run:
pip install -r requirements.txt
Documentation
To build the documentation, run:
nox -s docs
The HTML pages will be in docs/_build/html.
Metadata
Release files for cache-performance-model 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cache_performance_model-0.1.6.tar.gz | 11.3 kB | Without provenance | Details for cache_performance_model-0.1.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cache_performance_model-0.1.6-py3-none-any.whl | Python 3 | none | any | Details for cache_performance_model-0.1.6-py3-none-any.whl |
Total release size: 21.3 kB
Release files / cache_performance_model-0.1.6.tar.gz
| Download URL | cache_performance_model-0.1.6.tar.gz |
|---|---|
| Size | 11.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
306e84026ab9f376b867e7873e2d8e214108425f1bb7fdea33ff1ccbd4b1c95f
|
|
BLAKE2b-256 checksum How to use checksums |
4a3316b1b7c64b5b601fe020aad055800cede92061d436d820af202ecece6530
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.9
|
Release files / cache_performance_model-0.1.6-py3-none-any.whl
| Download URL | cache_performance_model-0.1.6-py3-none-any.whl |
|---|---|
| Size | 10.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ec91abb5d386c275a91e0bd4fed505b961c20cb139796c7163737f543485c539
|
|
BLAKE2b-256 checksum How to use checksums |
c43316270419997579b45ba6d3d2d5417d5df4ea3e588300c74dab86f85cd431
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.9
|
Security for cache-performance-model 0.1.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.