]>
Commit | Line | Data |
---|---|---|
1d09f67e TL |
1 | // Licensed to the Apache Software Foundation (ASF) under one or more |
2 | // contributor license agreements. See the NOTICE file distributed with | |
3 | // this work for additional information regarding copyright ownership. | |
4 | // The ASF licenses this file to You under the Apache License, Version 2.0 | |
5 | // (the "License"); you may not use this file except in compliance with | |
6 | // the License. You may obtain a copy of the License at | |
7 | // | |
8 | // http://www.apache.org/licenses/LICENSE-2.0 | |
9 | // | |
10 | // Unless required by applicable law or agreed to in writing, software | |
11 | // distributed under the License is distributed on an "AS IS" BASIS, | |
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | // See the License for the specific language governing permissions and | |
14 | // limitations under the License. | |
15 | ||
16 | using Apache.Arrow.Ipc; | |
17 | using Apache.Arrow.Tests; | |
18 | using BenchmarkDotNet.Attributes; | |
19 | using System.IO; | |
20 | using System.Threading.Tasks; | |
21 | ||
22 | namespace Apache.Arrow.Benchmarks | |
23 | { | |
24 | //[EtwProfiler] - needs elevated privileges | |
25 | [MemoryDiagnoser] | |
26 | public class ArrowWriterBenchmark | |
27 | { | |
28 | [Params(10_000, 1_000_000)] | |
29 | public int BatchLength{ get; set; } | |
30 | ||
31 | //Max column set count is 15 before reaching 2gb limit of memory stream | |
32 | [Params(10, 14)] | |
33 | public int ColumnSetCount { get; set; } | |
34 | ||
35 | private MemoryStream _memoryStream; | |
36 | private RecordBatch _batch; | |
37 | ||
38 | [GlobalSetup] | |
39 | public void GlobalSetup() | |
40 | { | |
41 | _batch = TestData.CreateSampleRecordBatch(BatchLength, ColumnSetCount, false); | |
42 | _memoryStream = new MemoryStream(); | |
43 | } | |
44 | ||
45 | [IterationSetup] | |
46 | public void Setup() | |
47 | { | |
48 | _memoryStream.Position = 0; | |
49 | } | |
50 | ||
51 | [Benchmark] | |
52 | public async Task WriteBatch() | |
53 | { | |
54 | ArrowStreamWriter writer = new ArrowStreamWriter(_memoryStream, _batch.Schema); | |
55 | await writer.WriteRecordBatchAsync(_batch); | |
56 | } | |
57 | } | |
58 | } |