-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make benchmarks work with existing docker-compose setup
- Loading branch information
1 parent
a2af5cc
commit ba91d3e
Showing
9 changed files
with
153 additions
and
55 deletions.
There are no files selected for viewing
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,4 @@ | ||
# Licensed to Elasticsearch B.V under one or more agreements. | ||
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License. | ||
# See the LICENSE file in the project root for more information | ||
|
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,4 @@ | ||
# Licensed to Elasticsearch B.V under one or more agreements. | ||
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License. | ||
# See the LICENSE file in the project root for more information | ||
|
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
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,44 @@ | ||
# Licensed to Elasticsearch B.V under one or more agreements. | ||
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License. | ||
# See the LICENSE file in the project root for more information | ||
|
||
# Licensed to Elasticsearch B.V. under one or more agreements. | ||
# Elasticsearch B.V. licenses this file to you under the Apache 2.0 License. | ||
# See the LICENSE file in the project root for more information. | ||
|
||
import random | ||
import functools | ||
from benchmarking.lib import benchmarks, Operation, RunnerConfig | ||
|
||
|
||
@functools.lru_cache() | ||
def small_doc(data_path): | ||
with open(data_path / "small/document.json", mode="rb") as f: | ||
return f.read() | ||
|
||
|
||
def setup_func(_: int, config: RunnerConfig) -> None: | ||
config.target_es.indices.delete(index="test-bench-index", ignore=404) | ||
config.target_es.indices.create(index="test-bench-index") | ||
config.target_es.cluster.health(wait_for_status="yellow") | ||
|
||
|
||
def run_func(n: int, config: RunnerConfig) -> None: | ||
resp = config.target_es.index( | ||
index="test-bench-index", | ||
id="%d-%d" % (n, random.randint(1, 10000)), | ||
body=small_doc(config.data_path), | ||
) | ||
assert resp["result"] == "created", resp["result"] | ||
|
||
|
||
benchmarks.register( | ||
Operation( | ||
action="index", | ||
category="core", | ||
run_func=run_func, | ||
setup_func=setup_func, | ||
num_warmups=100, | ||
num_repetitions=10000, | ||
) | ||
) |
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