Skip to content

Commit fd38b58

Browse files
committed
add new benchmark
1 parent 002a73a commit fd38b58

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System;
2+
using System.Linq;
3+
using BenchmarkDotNet.Attributes;
4+
using Elasticsearch.Net;
5+
using Nest;
6+
using Tests.Benchmarking.Framework;
7+
8+
namespace Tests.Benchmarking
9+
{
10+
[BenchmarkConfig]
11+
public class ConnectionMechanicsBenchmarkTests
12+
{
13+
private IElasticClient Client { get; set; }
14+
private PostData Post { get; set; }
15+
16+
[GlobalSetup]
17+
public void Setup()
18+
{
19+
Post = PostData.String("{}");
20+
21+
var nodes = Enumerable.Range(0, 100).Select(i => new Node(new Uri($"http://localhost:{i}"))).ToList();
22+
23+
var connectionPool = new SniffingConnectionPool(nodes);
24+
var connection = new InMemoryConnection();
25+
var settings = new ConnectionSettings(connectionPool, connection)
26+
.SniffOnStartup(false)
27+
.SniffOnConnectionFault(false);
28+
Client = new ElasticClient(settings);
29+
30+
}
31+
32+
33+
[Benchmark(Description = "SearchResponse", OperationsPerInvoke = 1000)]
34+
public void SearchResponse()
35+
{
36+
var response = Client.LowLevel.Search<VoidResponse>("index", Post);
37+
}
38+
}
39+
}

0 commit comments

Comments
 (0)