Skip to content

Commit d4cc760

Browse files
algolia-botmillotp
andcommitted
chore: generated code for commit 23fd55c. [skip ci]
Co-authored-by: Pierre Millot <[email protected]>
1 parent 23fd55c commit d4cc760

File tree

12 files changed

+408
-20
lines changed

12 files changed

+408
-20
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
2+
using System.Text.Json;
3+
using System.Text.RegularExpressions;
4+
using Algolia.Search.Clients;
5+
using Algolia.Search.Http;
6+
using Algolia.Search.Models.Common;
7+
using Algolia.Search.Models.Search;
8+
using Algolia.Search.Serializer;
9+
using Algolia.Search.Tests.Utils;
10+
using Algolia.Search.Transport;
11+
using Quibble.Xunit;
12+
using Xunit;
13+
14+
namespace Algolia.Search.benchmark;
15+
16+
public class SearchClientBenchmark
17+
{
18+
private Exception _ex;
19+
20+
public SearchClientBenchmark() { }
21+
22+
[Fact]
23+
public void Dispose() { }
24+
25+
[Fact(DisplayName = "benchmark the search method")]
26+
public async Task BenchmarkTest0()
27+
{
28+
SearchConfig _config = new SearchConfig("test-app-id", "test-api-key")
29+
{
30+
CustomHosts = new List<StatefulHost>
31+
{
32+
new()
33+
{
34+
Scheme = HttpScheme.Http,
35+
Url = "localhost",
36+
Port = 6682,
37+
Up = true,
38+
LastUse = DateTime.UtcNow,
39+
Accept = CallType.Read | CallType.Write,
40+
}
41+
}
42+
};
43+
var client = new SearchClient(_config);
44+
45+
for (int i = 0; i < 1000; i++)
46+
{
47+
var res = await client.SearchAsync<Hit>(
48+
new SearchMethodParams
49+
{
50+
Requests = new List<SearchQuery>
51+
{
52+
new SearchQuery(
53+
new SearchForHits
54+
{
55+
IndexName = "cts_e2e_benchmark_search_Csharp",
56+
Query = "iphone 15 pro max 512gb",
57+
HitsPerPage = 50,
58+
}
59+
)
60+
},
61+
}
62+
);
63+
}
64+
}
65+
}

tests/output/go/tests/benchmark/search_test.go

Lines changed: 57 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/output/go/tests/client/search_test.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package com.algolia.benchmark;
2+
3+
import com.algolia.api.SearchClient;
4+
import com.algolia.config.*;
5+
import com.algolia.model.search.*;
6+
import com.fasterxml.jackson.annotation.JsonInclude;
7+
import com.fasterxml.jackson.databind.DeserializationFeature;
8+
import com.fasterxml.jackson.databind.ObjectMapper;
9+
import com.fasterxml.jackson.databind.json.JsonMapper;
10+
import java.util.*;
11+
import org.junit.jupiter.api.BeforeAll;
12+
import org.junit.jupiter.api.DisplayName;
13+
import org.junit.jupiter.api.Test;
14+
import org.junit.jupiter.api.TestInstance;
15+
16+
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
17+
class SearchClientBenchmark {
18+
19+
private ObjectMapper json;
20+
21+
@BeforeAll
22+
void init() {
23+
this.json = JsonMapper.builder()
24+
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
25+
.serializationInclusion(JsonInclude.Include.NON_NULL)
26+
.build();
27+
}
28+
29+
private ClientOptions withCustomHosts(List<Host> hosts, boolean gzipEncoding) {
30+
return ClientOptions.builder().setHosts(hosts).setCompressionType(gzipEncoding ? CompressionType.GZIP : CompressionType.NONE).build();
31+
}
32+
33+
@Test
34+
@DisplayName("benchmark the search method")
35+
void benchmarkTest0() {
36+
SearchClient client = new SearchClient(
37+
"test-app-id",
38+
"test-api-key",
39+
withCustomHosts(Arrays.asList(new Host("localhost", EnumSet.of(CallType.READ, CallType.WRITE), "http", 6682)), false)
40+
);
41+
for (int i = 0; i < 1000; i++) {
42+
var res = client.search(
43+
new SearchMethodParams()
44+
.setRequests(
45+
List.of(
46+
new SearchForHits().setIndexName("cts_e2e_benchmark_search_Java").setQuery("iphone 15 pro max 512gb").setHitsPerPage(50)
47+
)
48+
),
49+
Hit.class
50+
);
51+
}
52+
}
53+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
2+
/* eslint-disable @typescript-eslint/no-unused-vars */
3+
// @ts-nocheck Failing tests will have type errors, but we cannot suppress them even with @ts-expect-error because it doesn't work for a block of lines.
4+
import type { SearchClient } from '@algolia/client-search';
5+
import { searchClient } from '@algolia/client-search';
6+
7+
const appId = 'test-app-id';
8+
const apiKey = 'test-api-key';
9+
10+
function createClient(): SearchClient {
11+
return searchClient(appId, apiKey, { requester: echoRequester() });
12+
}
13+
14+
describe('benchmark', () => {
15+
test('benchmark the search method', async () => {
16+
const client = searchClient('test-app-id', 'test-api-key', {
17+
hosts: [
18+
{ url: 'localhost', port: 6682, accept: 'readWrite', protocol: 'http' },
19+
],
20+
});
21+
22+
for (let i = 0; i < 1000; i++) {
23+
const result = await client.search({
24+
requests: [
25+
{
26+
indexName: 'cts_e2e_benchmark_search_JavaScript',
27+
query: 'iphone 15 pro max 512gb',
28+
hitsPerPage: 50,
29+
},
30+
],
31+
});
32+
}
33+
}, 15000);
34+
});
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
2+
package com.algolia.benchmark
3+
4+
import com.algolia.client.api.SearchClient
5+
import com.algolia.client.configuration.*
6+
import com.algolia.client.extensions.*
7+
import com.algolia.client.model.search.*
8+
import com.algolia.client.transport.*
9+
import com.algolia.utils.*
10+
import io.ktor.http.*
11+
import kotlinx.coroutines.test.*
12+
import kotlinx.serialization.json.*
13+
import kotlin.test.*
14+
15+
class SearchTest {
16+
17+
@Test
18+
fun `benchmark the search method`() = runTest {
19+
val client = SearchClient(appId = "test-app-id", apiKey = "test-api-key", options = ClientOptions(hosts = listOf(Host(url = "localhost", protocol = "http", port = 6682))))
20+
for (i in 1..1000) {
21+
client.runTest(
22+
call = {
23+
search(
24+
searchMethodParams = SearchMethodParams(
25+
requests = listOf(
26+
SearchForHits(
27+
indexName = "cts_e2e_benchmark_search_Kotlin",
28+
query = "iphone 15 pro max 512gb",
29+
hitsPerPage = 50,
30+
),
31+
),
32+
),
33+
)
34+
},
35+
)
36+
}
37+
}
38+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
4+
5+
namespace Algolia\AlgoliaSearch\Test\Benchmark;
6+
7+
use Algolia\AlgoliaSearch\Api\SearchClient;
8+
use Algolia\AlgoliaSearch\Configuration\SearchConfig;
9+
use PHPUnit\Framework\Attributes\CoversClass;
10+
use PHPUnit\Framework\Attributes\TestDox;
11+
use PHPUnit\Framework\TestCase;
12+
13+
/**
14+
* Benchmark for SearchClient.
15+
*
16+
* @internal
17+
*/
18+
#[CoversClass(SearchClient::class)]
19+
class SearchTest extends TestCase
20+
{
21+
#[TestDox('benchmark the search method')]
22+
public function test0benchmark()
23+
{
24+
$client = SearchClient::createWithConfig(SearchConfig::create('test-app-id', 'test-api-key')->setFullHosts(['http://localhost:6682']));
25+
26+
for ($i = 1; $i <= 1000; ++$i) {
27+
$res = $client->search(
28+
['requests' => [
29+
['indexName' => 'cts_e2e_benchmark_search_PHP',
30+
'query' => 'iphone 15 pro max 512gb',
31+
'hitsPerPage' => 50,
32+
],
33+
],
34+
],
35+
);
36+
}
37+
}
38+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
2+
3+
from algoliasearch.http.hosts import Host, HostsCollection
4+
from algoliasearch.search.client import SearchClient
5+
from algoliasearch.search.config import SearchConfig
6+
7+
8+
class TestSearchClient:
9+
async def test_benchmark_0(self):
10+
"""
11+
benchmark the search method
12+
"""
13+
14+
_config = SearchConfig("test-app-id", "test-api-key")
15+
_config.hosts = HostsCollection(
16+
[Host(url="localhost", scheme="http", port=6682)]
17+
)
18+
self._client = SearchClient.create_with_config(config=_config)
19+
for _ in range(0, 1000):
20+
_req = await self._client.search(
21+
search_method_params={
22+
"requests": [
23+
{
24+
"indexName": "cts_e2e_benchmark_search_Python",
25+
"query": "iphone 15 pro max 512gb",
26+
"hitsPerPage": 50,
27+
},
28+
],
29+
},
30+
)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
2+
require "algolia"
3+
require "test/unit"
4+
5+
class BenchmarkClientSearchClient < Test::Unit::TestCase
6+
include Algolia::Search
7+
# benchmark the search method
8+
def test_benchmark0
9+
client = Algolia::SearchClient.create_with_config(
10+
Algolia::Configuration.new(
11+
"test-app-id",
12+
"test-api-key",
13+
[
14+
Algolia::Transport::StatefulHost.new(
15+
"localhost",
16+
protocol: "http://",
17+
port: 6682,
18+
accept: CallType::READ | CallType::WRITE
19+
)
20+
],
21+
"searchClient"
22+
)
23+
)
24+
for i in 1..1000
25+
req = client.search(
26+
SearchMethodParams.new(
27+
requests: [
28+
SearchForHits.new(
29+
index_name: "cts_e2e_benchmark_search_Ruby",
30+
query: "iphone 15 pro max 512gb",
31+
hits_per_page: 50
32+
)
33+
]
34+
)
35+
)
36+
end
37+
end
38+
39+
end

0 commit comments

Comments
 (0)