evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build a task execution system that schedules tasks intelligently based on their historical execution times to optimize overall completion time.
Your system must track task execution history and use this data to optimize scheduling of future task runs.
interface TaskDefinition {
id: string;
execute: () => Promise<void>;
dependencies?: string[];
}
interface ExecutionRecord {
taskId: string;
duration: number;
timestamp: Date;
}
class TaskScheduler {
/**
* Creates a new task scheduler with a default estimated execution time
* for tasks with no historical data.
*/
constructor(defaultEstimatedTime: number);
/**
* Records the execution of a task and its duration in milliseconds.
*/
recordExecution(taskId: string, duration: number): void;
/**
* Gets the estimated execution time for a task based on historical data.
* Returns the average of all recorded executions, or the default if no history exists.
*/
getEstimatedTime(taskId: string): number;
/**
* Schedules and executes tasks in optimized order based on historical timing.
* Returns execution records for all completed tasks.
*/
executeTasks(tasks: TaskDefinition[]): Promise<ExecutionRecord[]>;
}Provides intelligent task scheduling and execution capabilities.