Exemplo n.º 1
0
        /// <summary>
        /// Sets the Task that will be benchmarked
        /// </summary>
        /// <param name="runner">The BenchmarkRunner</param>
        /// <param name="name">The name that defines the execution</param>
        /// <param name="task">The Task to benchmark</param>
        /// <returns></returns>
        public static ProfilerSession Task(this BenchmarkRunner runner, string name, Action task)
        {
            var session = ProfilerSession.StartSession()
                          .Task(task);

            runner.AddSession(name, session);

            return(session);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sets the Task that will be benchmarked
        /// </summary>
        /// <param name="runner">The BenchmarkRunner</param>
        /// <param name="name">The name that defines the execution</param>
        /// <param name="task">The Task to benchmark</param>
        /// <returns></returns>
        public static ProfilerSession Task <T>(this BenchmarkRunner runner, string name, Func <IExecutionContext, T> task)
        {
            var session = ProfilerSession.StartSession()
                          .Task(task);

            runner.AddSession(name, session);

            return(session);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Sets the Task that will be benchmarked
        /// </summary>
        /// <param name="runner">The BenchmarkRunner</param>
        /// <param name="name">The name that defines the execution</param>
        /// <param name="task">The Task to benchmark</param>
        /// <param name="parameter">The parameter that is passed to the tasks</param>
        /// <returns></returns>
        public static ProfilerSession Task <T>(this BenchmarkRunner runner, string name, Func <T, T> task, T parameter)
        {
            var session = ProfilerSession.StartSession()
                          .Task(task, parameter);

            runner.AddSession(name, session);

            return(session);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Sets a Task that will be executed after each profiling task execution
 /// </summary>
 /// <param name="session">The current session</param>
 /// <param name="task">The task to execute after each profiling task</param>
 /// <returns>The current profiling session</returns>
 public static ProfilerSession PostExecute(this ProfilerSession session, Action <IExecutionContext> task)
 {
     return(session.AddMiddleware(new PostExecutionTaskHandler(task)));
 }
Exemplo n.º 5
0
        /// <summary>
        /// Sets the duration that the profileing session should run the task for
        /// </summary>
        /// <param name="session">The current session</param>
        /// <param name="duration">The iterations to run the task</param>
        /// <returns>The current profiling session</returns>
        public static ProfilerSession SetDuration(this ProfilerSession session, TimeSpan duration)
        {
            session.Settings.Duration = duration;

            return(session);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Sets the amount of iterations that the profileing session should run the task
        /// </summary>
        /// <param name="session">The current session</param>
        /// <param name="iterations">The iterations to run the task</param>
        /// <returns>The current profiling session</returns>
        public static ProfilerSession SetIterations(this ProfilerSession session, int iterations)
        {
            session.Settings.Iterations = iterations;

            return(session);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Sets the Task that will be profiled passing the current ExecutionContext as parameter
        /// </summary>
        /// <typeparam name="T">The expected task output</typeparam>
        /// <param name="session">The current session</param>
        /// <param name="task">The task to execute</param>
        /// <returns>The current profiling session</returns>
        public static ProfilerSession Task <T>(this ProfilerSession session, Func <IExecutionContext, T> task)
        {
            session.Task(new OutputTask <T>(task));

            return(session);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Sets the Task that will be profiled passing the current ExecutionContext as parameter
        /// </summary>
        /// <param name="session">The current session</param>
        /// <param name="task">The task to execute</param>
        /// <returns>The current profiling session</returns>
        public static ProfilerSession Task(this ProfilerSession session, Action <IExecutionContext> task)
        {
            session.Task(new ContextTask(task));

            return(session);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Sets the Task that will be profiled
        /// </summary>
        /// <param name="session">The current session</param>
        /// <typeparam name="T">The return and parameter value</typeparam>
        /// <param name="task">The task to execute</param>
        /// <param name="parameter">The parameter that is passed to the task</param>
        /// <returns>The current profiling session</returns>
        public static ProfilerSession Task <T>(this ProfilerSession session, Func <T, T> task, T parameter)
        {
            session.Task(new Task <T>(task, parameter));

            return(session);
        }
Exemplo n.º 10
0
 /// <summary>
 /// Adds a setup task to the sessionpipeline
 /// </summary>
 /// <param name="session">The current session</param>
 /// <param name="setup">The setuptask</param>
 /// <returns>The current profiling session</returns>
 public static ProfilerSession Setup(this ProfilerSession session, Action setup)
 {
     return(session.AddMiddleware(new PreExecutionSessionHandler(setup)));
 }
Exemplo n.º 11
0
        /// <summary>
        /// The task will be executed at the given interval.
        /// To ensure the execution interval, the task is executed in a new thread
        /// </summary>
        /// <param name="session"></param>
        /// <param name="interval"></param>
        /// <returns></returns>
        public static ProfilerSession SetInterval(this ProfilerSession session, TimeSpan interval)
        {
            session.Settings.Execution = new TimedTaskExecution(interval);

            return(session);
        }
Exemplo n.º 12
0
 /// <summary>
 /// Add the middleware to the session pipeline
 /// </summary>
 /// <param name="session">The current session</param>
 /// <param name="middleware">The middleware to add</param>
 /// <returns></returns>
 public static ProfilerSession AddMiddleware(this ProfilerSession session, ISessionHandler middleware)
 {
     session.SessionPipeline.SetNext(middleware);
     return(session);
 }
Exemplo n.º 13
0
 /// <summary>
 /// Sets a Task that will be executed before each profiling task execution
 /// </summary>
 /// <param name="session">The current session</param>
 /// <param name="task">The task to execute before each profiling task</param>
 /// <returns>The current profiling session</returns>
 public static ProfilerSession PreExecute(this ProfilerSession session, Action task)
 {
     return(session.AddMiddleware(new PreExecutionTaskHandler(task)));
 }
Exemplo n.º 14
0
        /// <summary>
        /// Sets the Task that will be profiled
        /// </summary>
        /// <param name="session">The current session</param>
        /// <param name="task">The Task</param>
        /// <returns>The current profiling session</returns>
        public static ProfilerSession Task(this ProfilerSession session, Action task)
        {
            session.Task(new Task(task));

            return(session);
        }
Exemplo n.º 15
0
 /// <summary>
 /// Add the middleware to the processing pipeline
 /// </summary>
 /// <param name="session">The current session</param>
 /// <param name="middleware">The middleware to add</param>
 /// <returns></returns>
 public static ProfilerSession AddMiddleware(this ProfilerSession session, ITaskMiddleware middleware)
 {
     session.ProcessingPipeline.SetNext(middleware);
     return(session);
 }
Exemplo n.º 16
0
        /// <summary>
        /// Set values in the settings
        /// </summary>
        /// <param name="session">The current session</param>
        /// <param name="settings">The settings for thr profiler</param>
        /// <returns></returns>
        public static ProfilerSession Settings(this ProfilerSession session, Action <ProfilerSettings> settings)
        {
            settings(session.Settings);

            return(session);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Sets the settings that the profiler should use
        /// </summary>
        /// <param name="session">The current session</param>
        /// <param name="settings">The settings for thr profiler</param>
        /// <returns>The current profiling session</returns>
        public static ProfilerSession SetSettings(this ProfilerSession session, ProfilerSettings settings)
        {
            settings.MergeChangesTo(session.Settings);

            return(session);
        }
Exemplo n.º 18
0
        public static ProfilerSession RunWarmup(this ProfilerSession session, bool run)
        {
            session.Settings.RunWarmup = run;

            return(session);
        }
Exemplo n.º 19
0
 /// <summary>
 /// Add a delay before each task gets executed. The delay is not countet to the execution time of the task
 /// </summary>
 /// <param name="session"></param>
 /// <param name="duration"></param>
 /// <returns></returns>
 public static ProfilerSession AddDelay(this ProfilerSession session, TimeSpan duration)
 {
     return(session.AddMiddleware(new DelayTaskHandler(duration)));
 }
Exemplo n.º 20
0
        /// <summary>
        /// Add a new session to run benchmarks against
        /// </summary>
        /// <param name="name"></param>
        /// <param name="session"></param>
        /// <returns></returns>
        public BenchmarkRunner AddSession(string name, ProfilerSession session)
        {
            _sessions.Add(name, session);

            return(this);
        }