Exemplo n.º 1
0
        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();
            }
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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);
        }