Mirror Chart

GPU vs CPU Benchmark

Mirror histogram comparing processing times with speedup factor annotation

Output
GPU vs CPU Benchmark
Python
import numpy as np
import matplotlib.pyplot as plt

np.random.seed(321)
BG_COLOR = '#0a0a0f'

# Processing time (seconds)
cpu = np.random.gamma(8, 1.5, 800)
gpu = np.random.gamma(2, 0.4, 800)

fig, ax = plt.subplots(figsize=(12, 7), facecolor=BG_COLOR)
ax.set_facecolor(BG_COLOR)

bins = np.linspace(0, 25, 35)
bin_width = bins[1] - bins[0]
centers = (bins[:-1] + bins[1:]) / 2

# CPU (top) - warm colors
h1, _ = np.histogram(cpu, bins=bins, density=True)
ax.bar(centers, h1, width=bin_width*0.85, color='#F54927', alpha=0.75,
       edgecolor='#F54927', linewidth=1, label=f'CPU (μ={np.mean(cpu):.1f}s)')

# GPU (bottom) - cool colors
h2, _ = np.histogram(gpu, bins=bins, density=True)
ax.bar(centers, -h2, width=bin_width*0.85, color='#6CF527', alpha=0.75,
       edgecolor='#6CF527', linewidth=1, label=f'GPU (μ={np.mean(gpu):.1f}s)')

ax.axhline(0, color='#555555', linewidth=2)

# Speedup calculation
speedup = np.mean(cpu) / np.mean(gpu)

# Big speedup annotation
ax.text(20, max(h1)*0.6, f'{speedup:.1f}x', fontsize=48, color='#6CF527',
        fontweight='bold', ha='center', alpha=0.8)
ax.text(20, max(h1)*0.35, 'FASTER', fontsize=14, color='#6CF527',
        fontweight='bold', ha='center', alpha=0.8)

# Arrow showing improvement
ax.annotate('', xy=(np.mean(gpu), -max(h2)*0.7), xytext=(np.mean(cpu), max(h1)*0.7),
            arrowprops=dict(arrowstyle='->', color='#F5D327', lw=3,
                          connectionstyle='arc3,rad=-0.2'))

# Stats
stats = f"CPU: μ={np.mean(cpu):.1f}s, σ={np.std(cpu):.1f}s | GPU: μ={np.mean(gpu):.2f}s, σ={np.std(gpu):.2f}s"
ax.text(0.5, 0.98, stats, transform=ax.transAxes, ha='center', va='top',
        fontsize=10, color='#888888', fontfamily='monospace',
        bbox=dict(boxstyle='round,pad=0.4', facecolor=BG_COLOR, edgecolor='#333333'))

ax.set_xlabel('Processing Time (seconds)', fontsize=12, color='white', fontweight='500')
ax.set_title('Deep Learning Training: CPU vs GPU', fontsize=16, color='white', fontweight='bold', pad=25)

ax.tick_params(colors='#888888', labelsize=10)
ax.set_yticks([])
for spine in ['top', 'right']:
    ax.spines[spine].set_visible(False)
for spine in ['bottom', 'left']:
    ax.spines[spine].set_color('#333333')
ax.legend(loc='upper right', facecolor=BG_COLOR, edgecolor='#333333', labelcolor='white', fontsize=10)

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support