Estimating the empirical cost function of routines with dynamic workloads