def trace_driven_cache_hit_ratio(workload, cache, warmup_ratio=0.25):
    """Compute cache hit ratio of a cache under an arbitrary trace-driven
    workload.

    Parameters
    ----------
    workload : list or array
        List of URLs or content identifiers extracted from a trace. This list
        only needs to contains content identifiers and not timestamps
    cache : Cache
        Instance of a cache object
    warmup_ratio : float, optional
        Ratio of requests of the workload used to warm up the cache (i.e. whose
        cache hit/miss results are discarded)

    Returns
    -------
    cache_hit_ratio : float
        The cache hit ratio
    """
    if warmup_ratio < 0 or warmup_ratio > 1:
        raise ValueError("warmup_ratio must be comprised between 0 and 1")
    n = len(workload)
    cache_hits = 0
    n_warmup = int(warmup_ratio * n)
    n_req = 0
    for content in workload:
        if cache.get(content):
            if n_req >= n_warmup:
                cache_hits += 1
        else:
            cache.put(content)
        n_req += 1
    return cache_hits / (n - n_warmup)