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

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():
    data = random.sample(range(10000), 10000)
    
    # Benchmark quicksort
    start_time = time.time()
    sorted_data_quicksort = quicksort(data)
    quicksort_time = time.time() - start_time
    
    # Benchmark built-in sorted()
    start_time = time.time()
    sorted_data_builtin = sorted(data)
    sorted_time = time.time() - start_time
    
    print(f"Quicksort time: {quicksort_time:.6f} seconds")
    print(f"Built-in sorted() time: {sorted_time:.6f} seconds")
    print(f"First 10 elements (quicksort): {sorted_data_quicksort[:10]}")
    print(f"First 10 elements (sorted()): {sorted_data_builtin[:10]}")

if __name__ == '__main__':
    benchmark_quicksort()