2
Tachyon Demo - Self-contained profiling example.
3
Pure Python with no external imports for clean heatmap output.
7
1
1
def fibonacci(n):
8
"""Recursive fibonacci - creates deep call stacks."""
11
206
227
return fibonacci(n - 1) + fibonacci(n - 2)
15
"""Classic bubble sort - O(n^2) comparison sorting."""
18
2
2
for j in range(0, n - i - 1):
19
8
8
if arr[j] > arr[j + 1]:
20
2
2
arr[j], arr[j + 1] = arr[j + 1], arr[j]
24
def matrix_multiply(a, b):
25
"""Matrix multiplication using nested loops."""
26
rows_a, cols_a = len(a), len(a[0])
27
rows_b, cols_b = len(b), len(b[0])
28
result = [[0] * cols_b for _ in range(rows_a)]
30
for i in range(rows_a):
31
for j in range(cols_b):
32
8
8
for k in range(cols_a):
33
62
62
result[i][j] += a[i][k] * b[k][j]
37
def prime_sieve(limit):
38
"""Sieve of Eratosthenes - find all primes up to limit."""
39
is_prime = [True] * (limit + 1)
40
is_prime[0] = is_prime[1] = False
42
for num in range(2, int(limit ** 0.5) + 1):
44
1
1
for multiple in range(num * num, limit + 1, num):
45
is_prime[multiple] = False
47
2
2
return [num for num, prime in enumerate(is_prime) if prime]
50
def string_processing(iterations):
51
"""String operations - concatenation and formatting."""
52
for _ in range(iterations):
55
91
91
result += f"item_{i}_"
56
22
22
parts = result.split("_")
57
10
10
joined = "-".join(parts)
60
def list_operations(iterations):
61
"""List comprehensions and operations."""
62
for _ in range(iterations):
63
118
118
squares = [x ** 2 for x in range(500)]
64
119
119
evens = [x for x in squares if x % 2 == 0]
65
12
12
total = sum(evens)
68
def dict_operations(iterations):
69
"""Dictionary creation and lookups."""
70
for _ in range(iterations):
71
206
206
data = {f"key_{i}": i ** 2 for i in range(200)}
72
158
158
values = [data[f"key_{i}"] for i in range(200)]
73
5
5
total = sum(values)
77
"""CPU-intensive computation section."""
78
1
301
fibonacci(30)
81
a = [[i + j for j in range(size)] for i in range(size)]
82
b = [[i * j for j in range(size)] for i in range(size)]
88
def data_processing():
89
"""Data structure operations."""
90
753
string_processing(2000)
94
data = list(range(800))
97
bubble_sort(data[:200])
101
"""Main entry point."""
102
1,054
compute_heavy()
106
if __name__ == "__main__":