Пример #1
0
        private static void Main(string[] args)
        {
            var opts = new BenchmarkArgs();

            if (CommandLine.Parser.ParseArgumentsWithUsage(args, opts))
            {
                if (!string.IsNullOrEmpty(opts.LogFilePath))
                {
                    BenchmarkLogging.EnableFileLogging(opts.LogFilePath);
                    var logStream = new FileStream(opts.LogFilePath + ".bslog", FileMode.Create);
                    BrightstarListener = new TextWriterTraceListener(logStream);
                    BrightstarDB.Logging.BrightstarTraceSource.Listeners.Add(BrightstarListener);
                    BrightstarDB.Logging.BrightstarTraceSource.Switch.Level = SourceLevels.All;
                }
            }
            else
            {
                var usage = CommandLine.Parser.ArgumentsUsage(typeof(BenchmarkArgs));
                Console.WriteLine(usage);
            }
            var runner = new BenchmarkRunner(opts);

            runner.Run();
            BenchmarkLogging.Close();
            BrightstarDB.Logging.BrightstarTraceSource.Close();
        }
Пример #2
0
 private void WaitForAllExportsToComplete()
 {
     BenchmarkLogging.Info("Waiting for final export jobs to complete.");
     while (_activeJobList.Count > 0)
     {
         var toRemove = new List <string>();
         foreach (var jobId in _activeJobList)
         {
             var jobInfo = _brightstar.GetJobInfo(_storeName, jobId);
             if (jobInfo.JobCompletedWithErrors)
             {
                 BenchmarkLogging.Error("Export {0} failed. Cause: {1}. Detail {2}", jobInfo.Label,
                                        jobInfo.StatusMessage, jobInfo.ExceptionInfo);
                 toRemove.Add(jobId);
             }
             if (jobInfo.JobCompletedOk)
             {
                 ReportCompletedJob(jobInfo);
                 toRemove.Add(jobId);
             }
         }
         foreach (var r in toRemove)
         {
             _activeJobList.Remove(r);
         }
         Thread.Sleep(5000);
     }
 }
Пример #3
0
        private void WaitForAnExportToComplete()
        {
            var toRemove = new List <string>();

            while (toRemove.Count == 0 && _activeJobList.Count >= MaxExportJobCount)
            {
                foreach (var jobId in _activeJobList)
                {
                    var jobInfo = _brightstar.GetJobInfo(_storeName, jobId);
                    if (jobInfo.JobCompletedWithErrors)
                    {
                        BenchmarkLogging.Error("Export {0} failed. Cause: {1}. Detail {2}", jobInfo.Label,
                                               jobInfo.StatusMessage, jobInfo.ExceptionInfo);
                        toRemove.Add(jobId);
                    }
                    if (jobInfo.JobCompletedOk)
                    {
                        ReportCompletedJob(jobInfo);
                        toRemove.Add(jobId);
                    }
                }
                if (toRemove.Count == 0)
                {
                    BenchmarkLogging.Debug("Waiting for export jobs...");
                    Thread.Sleep(5000);
                }
            }
            foreach (var id in toRemove)
            {
                _activeJobList.Remove(id);
            }
        }
Пример #4
0
 public BenchmarkRunner(BenchmarkArgs args)
 {
     SourceFiles = Directory.GetFiles(args.TestDataDirectory, "*.nt", SearchOption.AllDirectories);
     BenchmarkLogging.Info("Found {0} source NTriples files for benchmark test", SourceFiles.Length);
     if (args.MaxNumberFiles > 0 && args.MaxNumberFiles < SourceFiles.Length)
     {
         SourceFiles = SourceFiles.Take(args.MaxNumberFiles).ToArray();
         BenchmarkLogging.Info("Limited number of source files to be processed to {0} (from command-line options)", SourceFiles.Length);
     }
     _brightstar = new EmbeddedBrightstarService(".");
     _storeName  = "BenchmarkStore_" + DateTime.Now.ToString("yyMMdd_HHmmss");
 }
Пример #5
0
        private void ImportSourceFile(int sourceFileIndex)
        {
            var fullText  = File.ReadAllText(SourceFiles[sourceFileIndex]);
            var lineCount = CountLines(SourceFiles[sourceFileIndex]);
            var sw        = Stopwatch.StartNew();

            _brightstar.ExecuteTransaction(_storeName, new UpdateTransactionData {
                InsertData = fullText
            });
            var importTime = sw.ElapsedMilliseconds;

            BenchmarkLogging.Info("IMPORT: {0},{1},{2}", _triplesImported, _triplesImported + lineCount, importTime);
            _triplesImported += lineCount;
        }
Пример #6
0
        private void ReportCompletedJob(IJobInfo jobInfo)
        {
            var expectedCount = Int32.Parse(jobInfo.Label.Split('_').Last());

            BenchmarkLogging.Info("EXPORT {0}, {1}", expectedCount, jobInfo.EndTime.Subtract(jobInfo.StartTime).TotalMilliseconds);
            var actualCount = CountLines("import" + Path.DirectorySeparatorChar + jobInfo.Label + ".nt");

            if (expectedCount == actualCount)
            {
                BenchmarkLogging.Info("Validated expected number of triples exported in {0}.nt", jobInfo.Label);
            }
            else
            {
                BenchmarkLogging.Error("Exported triple count in file {0}.nt does not match the expected count. (Expected: {1}, Counted: {2})",
                                       jobInfo.Label, expectedCount, actualCount);
            }
        }