import quantum_decomp as qd
from scipy.stats import unitary_group
from collections import Counter
import time


for qubits_count in range(1,10):
    time_start = time.time() 
    gates = qd.matrix_to_gates(unitary_group.rvs(2 ** qubits_count))
    duration = time.time() - time_start
    total = len(gates)
    print("%d qubits" % qubits_count)
    ctr = Counter([gate.type() for gate in gates])
    for t, count in ctr.most_common(10):
        print("%s: %d" % (t, count))
    print("%d total, %.02f gates per matrix element." % (total,  total/(4**qubits_count)))
    print("Time: %.03fs" % duration)
    
    print("\n")