public SampleResult RunSampleTest(int sampleSize) { Console.WriteLine($"Attempting to hash [{sampleSize}] values in stress test:"); Console.WriteLine(); TaskList = CreateWorkTasks(sampleSize); var stopwatch = new StopwatchWorker(); stopwatch.Start(); var processCounters = new ProcessCounters(); HashSampleSet(ref processCounters); stopwatch.Stop(); var result = new SampleResult { NumberOfThreads = processCounters.ThreadCount, SucceededItems = processCounters.SuccessCount, FailedItems = processCounters.FailureCount, Duration = stopwatch.ElapsedTime() }; DisplayWorker.DisplayResultSummary(result.SucceededItems, result.FailedItems, result.NumberOfThreads, result.Duration); return(result); }
private Task <ExternalTaskSuccessResult <SampleResult> > Callback(ExternalTask <TestPayload> externalTask) { this.testObject.Stop(); var samplePayload = new SampleResult(); return(Task.Run <ExternalTaskSuccessResult <SampleResult> >(() => { return new ExternalTaskSuccessResult <SampleResult>(externalTask.Id, samplePayload); })); }
private static TallyAction CreateTally(string unitCode, TallyPopulation population, SampleResult sampleResult, int treeCount = 1, int kpi = 0, int threePRandomeValue = 0, bool stm = false) { var tallyEntry = new TallyAction(unitCode, population) { SampleResult = sampleResult, //CountOrMeasure = countOrMeasure, TreeCount = treeCount, KPI = kpi, ThreePRandomValue = threePRandomeValue, STM = stm, }; return(tallyEntry); }
private IResponse CsvSample(IRequestContext ctx, Route route) { if (!ctx.Request.HasBody) { return(ArribaResponse.BadRequest("Empty request body")); } SampleResult result = new SampleResult(); var config = new CsvReaderSettings() { DisposeStream = true, HasHeaders = true }; using (CsvReader reader = new CsvReader(ctx.Request.InputStream, config)) { // Read the CSV fragment into a DataBlock DataBlock block = reader.ReadAsDataBlockBatch(10000, true).FirstOrDefault(); if (block == null) { return(ArribaResponse.BadRequest("No result content found.")); } // Count the rows actually returned result.RowCount = block.RowCount + 1; // Insert only the first 100 rows and not the last (partial) row block.SetRowCount(Math.Min(block.RowCount - 1, 100)); // Build a table with the sample Table sample = new Table("Sample", 100); sample.AddOrUpdate(block, new AddOrUpdateOptions() { AddMissingColumns = true }); // Return the created columns in the order they appeared in the CSV result.Columns = sample.ColumnDetails.OrderBy((cd) => block.IndexOfColumn(cd.Name)).ToList(); // Return the columns and row count from the sample return(ArribaResponse.Ok(result)); } }
public ActionResult <SampleResult> Update([FromBody] SampleAccount account) { // api call unique sequence long requestNo = (long)HttpContext.Items["RequestNo"]; _logger.LogInformation($"[{requestNo}] start api controller..."); // db process //using (var conn = _dbService["DB"]) //{ // var result = conn.Query("SELECT * FROM [dbo].[GT_ACCOUNT]"); //} SampleResult result = new SampleResult(); result.ResultCode = 0; result.ResultMessage = "Success api call"; _logger.LogInformation($"[{requestNo}] end api controller"); return(result); }
[InlineData("st3", "sg1", "sp1", "L", SampleResult.I)] // tally by subpop - insurance public void InsertTallyAction(string stratumCode, string sgCode, string species, string liveDead, SampleResult sampleResult) { var unitCode = "u1"; var treeCount = 50; using (var database = CreateDatabase()) { var datastore = new TallyDataservice(database, CruiseID, TestDeviceInfoService.TEST_DEVICEID, new SamplerInfoDataservice(database, CruiseID, TestDeviceInfoService.TEST_DEVICEID)); var tpds = new TallyPopulationDataservice(database, CruiseID, TestDeviceInfoService.TEST_DEVICEID); var cuds = new CuttingUnitDatastore(database, CruiseID, TestDeviceInfoService.TEST_DEVICEID, new SamplerInfoDataservice(database, CruiseID, TestDeviceInfoService.TEST_DEVICEID)); var tallyPops = database.QueryGeneric($"Select * from TallyPopulation WHERE StratumCode = '{stratumCode}';") .ToArray(); var pop = tpds.GetTallyPopulation(unitCode, stratumCode, sgCode, species, liveDead); pop.Should().NotBeNull(); var tallyAction = new TallyAction(unitCode, pop) { SampleResult = sampleResult, TreeCount = treeCount, }; var entry = datastore.InsertTallyAction(tallyAction); entry.TallyLedgerID.Should().NotBeEmpty(); ValidateTallyEntry(entry, sampleResult == SampleResult.M || sampleResult == SampleResult.I); var entryAgain = datastore.GetTallyEntry(entry.TallyLedgerID); ValidateTallyEntry(entryAgain, sampleResult == SampleResult.M || sampleResult == SampleResult.I); //var tree = database.From<Tree>().Where("TreeID = @p1").Query(entry.TreeID).FirstOrDefault(); if (sampleResult == SampleResult.M || sampleResult == SampleResult.I) { var tree = cuds.GetTree(entry.TreeID); tree.Should().NotBeNull(); tree.TreeID.Should().Be(entry.TreeID); tree.StratumCode.Should().Be(stratumCode); tree.SampleGroupCode.Should().Be(sgCode); tree.SpeciesCode.Should().Be(pop.SpeciesCode); tree.LiveDead.Should().Be(pop.LiveDead); tree.CountOrMeasure.Should().Be(sampleResult.ToString()); } var tallyPopulate = tpds.GetTallyPopulationsByUnitCode(unitCode).Where(x => (x.SpeciesCode ?? "") == (species ?? "")).Single(); tallyPopulate.TreeCount.Should().Be(treeCount); } }
public SampleResult March(DistanceField field, double minimum, double maximum, Vec3 fog) { SampleResult result = field.Sample(CurrentPosition); while (true) { if (result.Distance < minimum) { break; } if (DistanceTraveled > maximum) { DistanceTraveled = maximum; break; } CurrentPosition = CurrentPosition + Direction * result.Distance; DistanceTraveled += result.Distance; result = field.Sample(CurrentPosition); } var bouncedColor = Vec3.Zero; if (result.Source) { bouncedColor = result.Color; } else if (DistanceTraveled < maximum) { var colorSum = Vec3.Zero; Vec3 target = result.Normal + Vec3.Random(); // Linearly interpolate between the perfect reflection and the scattered normal. if (ThreadSafeRandom.NextDouble() < result.Reflectance) { var reflectionTarget = Direction - 2 * result.Normal * result.Normal.Dot(Direction); target = reflectionTarget * (1 - result.Roughness) + target * result.Roughness; } var ray = new Ray(CurrentPosition + result.Normal * minimum * 2, target); var reflectionResult = ray.March(field, minimum, maximum - DistanceTraveled, fog); var rAmount = Utils.Interpolate(result.Color.X, 1, result.Reflectance); var gAmount = Utils.Interpolate(result.Color.Y, 1, result.Reflectance); var bAmount = Utils.Interpolate(result.Color.Z, 1, result.Reflectance); bouncedColor = new Vec3( reflectionResult.Color.X * rAmount * (1 - result.Absorbance), reflectionResult.Color.Y * gAmount * (1 - result.Absorbance), reflectionResult.Color.Z * bAmount * (1 - result.Absorbance) ); } else { bouncedColor = new Vec3(1.0, 0.0, 0.0); } var fogAmount = DistanceTraveled / maximum; if (maximum == 0) { fogAmount = 1; } result.Color = Utils.Interpolate(bouncedColor, fog, fogAmount); return(result); }