#!/usr/bin/env python3
"""Auto-generated by AGI Loop cycle #1025
Task: Write a Python function that implements quicksort and benchmarks it vs sorted() on 10000 random ints
Generated: 2026-02-12T17:28:50.218076
"""

import random
import time

def quicksort(arr):
    if len(arr) <= 1:
        return arr
    pivot = arr[len(arr) // 2]
    left = [x for x in arr if x < pivot]
    middle = [x for x in arr if x == pivot]
    right = [x for x in arr if x > pivot]
    return quicksort(left) + middle + quicksort(right)

def benchmark_quicksort_vs_sorted():
    data = random.sample(range(10000), 10000)

    # Benchmark quicksort
    start_time = time.time()
    sorted_data_quicksort = quicksort(data.copy())
    quicksort_time = time.time() - start_time
    print(f"Quicksort time: {quicksort_time:.6f} seconds")

    # Benchmark built-in sorted()
    start_time = time.time()
    sorted_data_sorted = sorted(data.copy())
    sorted_time = time.time() - start_time
    print(f"Built-in sorted() time: {sorted_time:.6f} seconds")

if __name__ == '__main__':
    benchmark_quicksort_vs_sorted()