private void RunCore( Benchmark benchmark, IRunnableBenchmark runnableBenchmark, ILogger logger, IDiagnoser diagnoser, BlockingStream outputStream) { var outputWriter = new StreamWriter(outputStream); var process = Process.GetCurrentProcess(); try { runnableBenchmark.Init(benchmark, outputWriter); diagnoser?.ProcessStarted(process); runnableBenchmark.Run(); diagnoser?.AfterBenchmarkHasRun(benchmark, process); } catch (Exception ex) { logger.WriteLineError($"// ! {GetType().Name}, exception: {ex}"); } finally { diagnoser?.ProcessStopped(process); outputWriter.Flush(); outputStream.CompleteWriting(); } }
public async Task <FileHeader> Execute(IAsyncFilesSession session) { var commands = session.Commands; var pipe = new BlockingStream(10); Task.Run(() => StreamWriter(pipe)) .ContinueWith(x => pipe.CompleteWriting()) .ConfigureAwait(false); if (sessionOperations.EntityChanged(Filename)) { if (!sessionOperations.IsDeleted(Filename)) { var fileHeaderInCache = await session.LoadFileAsync(Filename); Metadata = fileHeaderInCache.Metadata; } } await commands.UploadAsync(Filename, pipe, Metadata, Size, null) .ConfigureAwait(false); var metadata = await commands.GetMetadataForAsync(Filename); if (metadata == null) { return(null); } return(new FileHeader(Filename, metadata)); }
public async Task Execute(IAsyncFilesSession session) { var commands = session.Commands; var pipe = new BlockingStream(10); var task = Task.Run(() => StreamWriter(pipe)) .ContinueWith(x => { pipe.CompleteWriting(); }) .ConfigureAwait(false); await commands.UploadAsync(Path, pipe, Metadata, Size, null) .ConfigureAwait(false); }