performance/SqlTriggerPerformance_PollingIntervalOverride.cs (38 lines of code) (raw):

// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. using System.Threading.Tasks; using Microsoft.Azure.WebJobs.Extensions.Sql.Samples.TriggerBindingSamples; using Microsoft.Azure.WebJobs.Extensions.Sql.Tests.Common; using BenchmarkDotNet.Attributes; using System.Collections.Generic; namespace Microsoft.Azure.WebJobs.Extensions.Sql.Performance { [MemoryDiagnoser] public class SqlTriggerBindingPerformance_PollingIntervalOverride : SqlTriggerBindingPerformanceTestBase { [Params(1, 10, 100, 500, 2000)] public int PollingIntervalMs; [GlobalSetup] public void GlobalSetup() { this.SetChangeTrackingForTable("Products", true); this.StartFunctionHost( nameof(ProductsTrigger), SupportedLanguages.CSharp, environmentVariables: new Dictionary<string, string>() { { "Sql_Trigger_PollingIntervalMs", this.PollingIntervalMs.ToString() } }); } [Benchmark] public async Task Run() { int count = SqlOptions.DefaultMaxBatchSize * 2; await this.WaitForProductChanges( 1, count, SqlChangeOperation.Insert, () => { this.InsertProducts(1, count); return Task.CompletedTask; }, id => $"Product {id}", id => id * 100, this.GetBatchProcessingTimeout(1, count, pollingIntervalMs: this.PollingIntervalMs)); } } }