-
Notifications
You must be signed in to change notification settings - Fork 362
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert BigQuery field validation from a regex to hand-written code
This is entirely for the sake of performance. Benchmark results on my machine: netcoreapp2.0: - Short: 180ns => 9ns - Long: 939ns => 96ns netcoreapp3.1: - Short: 159ns => 8ns - Long: 887ns => 79ns net461: - Short: 197ns => 8ns - Long: 1425ns => 86ns Fixes #4975
- Loading branch information
Showing
5 changed files
with
67 additions
and
10 deletions.
There are no files selected for viewing
5 changes: 2 additions & 3 deletions
5
...igQuery.V2/Google.Cloud.BigQuery.V2.Benchmarks/Google.Cloud.BigQuery.V2.Benchmarks.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...ogle.Cloud.BigQuery.V2/Google.Cloud.BigQuery.V2.Benchmarks/TableSchemaBuilderBenchmark.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2020 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using BenchmarkDotNet.Attributes; | ||
|
||
namespace Google.Cloud.BigQuery.V2.Benchmarks | ||
{ | ||
public class TableSchemaBuilderBenchmark | ||
{ | ||
private const string ShortFieldName = "abc"; | ||
private const string LongFieldName = "abcdefghijklmnopqrstuvwxyz1234567890_ABCDEFGHIJKLMNOPQRSTUVWXYZ"; | ||
|
||
[Benchmark] | ||
public void ValidateFieldName_Short() => TableSchemaBuilder.ValidateFieldName(ShortFieldName, "param"); | ||
|
||
[Benchmark] | ||
public void ValidateFieldName_Long() => TableSchemaBuilder.ValidateFieldName(LongFieldName, "param"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters