public void TestRandomWrite()
        {
            var performanceRequest = new PerformanceTestRequest
            {
                FileSize = (long)128 * 1024,
                OperationType = OperationType.Write,
                Path = Path.Combine(Path.GetTempPath(), "data.ravendb-io-test"),
                Sequential = false,
                ThreadCount = 4,
                TimeToRunInSeconds = 5,
                ChunkSize = 4 * 1024
            };

            var tester = new DiskPerformanceTester(performanceRequest, s => { });
            tester.TestDiskIO();
            var result = tester.Result;
            Assert.Equal(0, result.TotalRead);
            Assert.True(result.TotalWrite > 0);
        }
Exemple #2
0
		private static void Main(string[] args)
		{
            var performanceRequest = new PerformanceTestRequest
            {
                FileSize = (long) 1024 * 1024 * 1024,
                OperationType = OperationType.Read,
                BufferingType = BufferingType.ReadAndWrite,
                Path = "c:\\temp\\data.ravendb-io-test",
                Sequential = true,
                ThreadCount = 4,
                TimeToRunInSeconds = 100,
                ChunkSize = 4 * 1024
            };

            var tester = new DiskPerformanceTester(performanceRequest, Console.WriteLine, CancellationToken.None);
            tester.TestDiskIO();

		    var r = tester.Result;

            Console.WriteLine(RavenJObject.FromObject(r));
		    Console.ReadKey();
		}
        public void TestCanCancelPerformanceTest()
        {
            var cts = new CancellationTokenSource();
            cts.CancelAfter(TimeSpan.FromSeconds(5));

            var performanceRequest = new PerformanceTestRequest
            {
                FileSize = (long)128 * 1024,
                OperationType = OperationType.Mix,
                Path = Path.Combine(Path.GetTempPath(), "data.ravendb-io-test"),
                Sequential = false,
                ThreadCount = 4,
                TimeToRunInSeconds = 30,
                ChunkSize = 4 * 1024
            };

            var tester = new DiskPerformanceTester(performanceRequest, s => { }, cts.Token);
            Assert.Throws<OperationCanceledException>(() => tester.TestDiskIO());
        }
Exemple #4
0
        public static void IoTest(PerformanceTestRequest request)
        {
            var tester = new DiskPerformanceTester(request, Console.WriteLine);
            tester.DescribeTestParameters();
            tester.TestDiskIO();
            var result = tester.Result;

            var hasReads = request.OperationType == OperationType.Read || request.OperationType == OperationType.Mix;
            var hasWrites = request.OperationType == OperationType.Write || request.OperationType == OperationType.Mix;

            if (hasReads)
            {
                var sb = new StringBuilder();
                sb.AppendLine(string.Format("Total read: {0}", SizeHelper.Humane(result.TotalRead)));
                sb.AppendLine(string.Format("Average read: {0}/s", SizeHelper.Humane(result.TotalRead / request.TimeToRunInSeconds)));
                sb.AppendLine("Read latency");
                sb.AppendLine(string.Format("\tMin:   {0:#,#.##;;0}", result.ReadLatency.Min));
                sb.AppendLine(string.Format("\tMean:  {0:#,#.##;;0}", result.ReadLatency.Mean));
                sb.AppendLine(string.Format("\tMax:   {0:#,#.##;;0}", result.ReadLatency.Max));
                sb.AppendLine(string.Format("\tStdev: {0:#,#.##;;0}", result.ReadLatency.Stdev));

                sb.AppendLine("Read latency percentiles");
                foreach (var percentile in result.ReadLatency.Percentiles)
                {
                    sb.AppendLine(string.Format("\t{0}: {1:#,#.##;;0}", percentile.Key, percentile.Value));
                }

                sb.AppendLine();
                Console.WriteLine(sb.ToString());
            }
            if (hasWrites)
            {
                var sb = new StringBuilder();
                sb.AppendLine(string.Format("Total write: {0}", SizeHelper.Humane(result.TotalWrite)));
                sb.AppendLine(string.Format("Average write: {0}/s", SizeHelper.Humane(result.TotalWrite / request.TimeToRunInSeconds)));
                sb.AppendLine("Write latency");
                sb.AppendLine(string.Format("\tMin:   {0:#,#.##;;0}", result.WriteLatency.Min));
                sb.AppendLine(string.Format("\tMean:  {0:#,#.##;;0}", result.WriteLatency.Mean));
                sb.AppendLine(string.Format("\tMax:   {0:#,#.##;;0}", result.WriteLatency.Max));
                sb.AppendLine(string.Format("\tStdev: {0:#,#.##;;0}", result.WriteLatency.Stdev));

                sb.AppendLine("Write latency percentiles");
                foreach (var percentile in result.WriteLatency.Percentiles)
                {
                    sb.AppendLine(string.Format("\t{0}: {1:#,#.##;;0}", percentile.Key, percentile.Value));
                }

                sb.AppendLine();
                Console.WriteLine(sb.ToString());
            }

        }
		public async Task<HttpResponseMessage> IoTest()
		{
			if (EnsureSystemDatabase() == false)
			{
				return GetMessageWithString("IO Test is only possible from the system database", HttpStatusCode.BadRequest);
			}
			var ioTestRequest = await ReadJsonObjectAsync<PerformanceTestRequest>();

			if (Directory.Exists(ioTestRequest.Path) == false)
			{
				return GetMessageWithString(string.Format("Directory {0} doesn't exist.", ioTestRequest.Path), HttpStatusCode.BadRequest);
			}
			ioTestRequest.Path = Path.Combine(ioTestRequest.Path, DiskPerformanceTester.TemporaryFileName);

			Database.Documents.Delete(DiskPerformanceTester.PerformanceResultDocumentKey, null, null);

			var killTaskCts = new CancellationTokenSource();

			var task = Task.Factory.StartNew(() =>
			{
				var debugInfo = new List<string>();

				var diskIo = new DiskPerformanceTester(ioTestRequest, debugInfo.Add, killTaskCts.Token);
				diskIo.TestDiskIO();

				var diskIoRequestAndResponse = new
				{
					Request = ioTestRequest,
					Result = diskIo.Result,
					DebugMsgs = debugInfo
				};

				Database.Documents.Put(DiskPerformanceTester.PerformanceResultDocumentKey, null, RavenJObject.FromObject(diskIoRequestAndResponse), new RavenJObject(), null);
			});

			long id;
			Database.Tasks.AddTask(task, new TaskBasedOperationState(task), new TaskActions.PendingTaskDescription
			{
				StartTime = SystemTime.UtcNow,
				TaskType = TaskActions.PendingTaskType.IoTest,
				Payload = "Disk performance test"
			}, out id, killTaskCts);

			return GetMessageWithObject(new
			{
				OperationId = id
			});
			/*

           

			var task = Task.Factory.StartNew(() =>
			{
				MaintenanceActions.Restore(ravenConfiguration,restoreRequest,
					msg =>
					{
						restoreStatus.Messages.Add(msg);
						DatabasesLandlord.SystemDatabase.Documents.Put(RestoreStatus.RavenRestoreStatusDocumentKey, null,
							RavenJObject.FromObject(restoreStatus), new RavenJObject(), null);
					});

				if (databaseDocument == null)
					return;

				databaseDocument.Settings[Constants.RavenDataDir] = documentDataDir;
				if (restoreRequest.IndexesLocation != null)
					databaseDocument.Settings[Constants.RavenIndexPath] = restoreRequest.IndexesLocation;
				if (restoreRequest.JournalsLocation != null)
					databaseDocument.Settings[Constants.RavenTxJournalPath] = restoreRequest.JournalsLocation;
				databaseDocument.Id = databaseName;
				DatabasesLandlord.Protect(databaseDocument);
				DatabasesLandlord.SystemDatabase.Documents.Put("Raven/Databases/" + databaseName, null, RavenJObject.FromObject(databaseDocument),
					new RavenJObject(), null);

				restoreStatus.Messages.Add("The new database was created");
				DatabasesLandlord.SystemDatabase.Documents.Put(RestoreStatus.RavenRestoreStatusDocumentKey, null,
					RavenJObject.FromObject(restoreStatus), new RavenJObject(), null);

				Database.Documents.Delete(RestoreInProgress.RavenRestoreInProgressDocumentKey, null, null);
			}, TaskCreationOptions.LongRunning);

			long id;
			Database.Tasks.AddTask(task, new TaskBasedOperationState(task), new TaskActions.PendingTaskDescription
			{
				StartTime = SystemTime.UtcNow,
				TaskType = TaskActions.PendingTaskType.RestoreDatabase,
				Payload = "Restoring database " + databaseName + " from " + restoreRequest.BackupLocation
			}, out id);


			return GetMessageWithObject(new
			{
				OperationId = id
			});*/
		}