44 lines
1.7 KiB
Python
44 lines
1.7 KiB
Python
"""
|
|
Linux BenchTools - Benchmark Model
|
|
"""
|
|
|
|
from sqlalchemy import Column, Integer, Float, DateTime, String, Text, ForeignKey
|
|
from sqlalchemy.orm import relationship
|
|
from datetime import datetime
|
|
from app.db.base import Base
|
|
|
|
|
|
class Benchmark(Base):
|
|
"""
|
|
Benchmark run results
|
|
"""
|
|
__tablename__ = "benchmarks"
|
|
|
|
id = Column(Integer, primary_key=True, index=True, autoincrement=True)
|
|
device_id = Column(Integer, ForeignKey("devices.id"), nullable=False, index=True)
|
|
hardware_snapshot_id = Column(Integer, ForeignKey("hardware_snapshots.id"), nullable=False)
|
|
run_at = Column(DateTime, nullable=False, default=datetime.utcnow, index=True)
|
|
bench_script_version = Column(String(50), nullable=False)
|
|
|
|
# Scores
|
|
global_score = Column(Float, nullable=False)
|
|
cpu_score = Column(Float, nullable=True)
|
|
cpu_score_single = Column(Float, nullable=True) # Monocore CPU score
|
|
cpu_score_multi = Column(Float, nullable=True) # Multicore CPU score
|
|
memory_score = Column(Float, nullable=True)
|
|
disk_score = Column(Float, nullable=True)
|
|
network_score = Column(Float, nullable=True)
|
|
gpu_score = Column(Float, nullable=True)
|
|
|
|
# Details
|
|
details_json = Column(Text, nullable=False) # JSON object with all raw results
|
|
network_results_json = Column(Text, nullable=True) # Network benchmark details (iperf3)
|
|
notes = Column(Text, nullable=True)
|
|
|
|
# Relationships
|
|
device = relationship("Device", back_populates="benchmarks")
|
|
hardware_snapshot = relationship("HardwareSnapshot", back_populates="benchmarks")
|
|
|
|
def __repr__(self):
|
|
return f"<Benchmark(id={self.id}, device_id={self.device_id}, global_score={self.global_score}, run_at='{self.run_at}')>"
|