presto-main/src/main/java/io/prestosql/sql/planner/optimizations/StatsRecordingPlanOptimizer.java/StatsRecordingPlanOptimizer/optimize
class StatsRecordingPlanOptimizer:    @Override
    public final PlanNode optimize(
            PlanNode plan,
            Session session,
            TypeProvider types,
            SymbolAllocator symbolAllocator,
            PlanNodeIdAllocator idAllocator,
            WarningCollector warningCollector)
    {
        PlanNode result;
        long duration;
        try {
            long start = System.nanoTime();
            result = delegate.optimize(plan, session, types, symbolAllocator, idAllocator, warningCollector);
            duration = System.nanoTime() - start;
        }
        catch (RuntimeException e) {
            stats.recordFailure(delegate);
            throw e;
        }
        stats.record(delegate, duration);
        return result;
    }