Beispiel #1
0
        internal override async Task <string> Run(Uri uri, CancellationToken cancellationToken)
        {
            if (cts != null)
            {
                throw new InvalidOperationException();
            }

            this.uri         = uri;
            this.mode        = (BenchmarkViewController.ModeTag)ViewController.Mode;
            this.repeatCount = ViewController.RepeatCount;
            cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);

            var message = string.Format(
                "Running {0} iterations of {1} ({2}).", repeatCount, mode, uri);

            OnMessageEvent(message);
            WriteLine(message);

            startTime = DateTime.Now;

            try {
                await DoRun();

                var time      = DateTime.Now - startTime;
                var completed = string.Format("Benchmark completed in {0}.", time);
                WriteLine(completed);
                WriteLine(string.Empty);
                return(message);
            } finally {
                cts.Dispose();
                cts = null;
            }
        }
		internal override async Task<string> Run (Uri uri, CancellationToken cancellationToken)
		{
			if (cts != null)
				throw new InvalidOperationException ();

			this.uri = uri;
			this.mode = (BenchmarkViewController.ModeTag)ViewController.Mode;
			this.repeatCount = ViewController.RepeatCount;
			cts = CancellationTokenSource.CreateLinkedTokenSource (cancellationToken);

			var message = string.Format (
				"Running {0} iterations of {1} ({2}).", repeatCount, mode, uri);
			OnMessageEvent (message);
			WriteLine (message);

			startTime = DateTime.Now;

			try {
				await DoRun ();
				var time = DateTime.Now - startTime;
				var completed = string.Format ("Benchmark completed in {0}.", time);
				WriteLine (completed);
				WriteLine (string.Empty);
				return message;
			} finally {
				cts.Dispose ();
				cts = null;
			}
		}