Skip to content

Commit

Permalink
Update benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jopel committed Oct 2, 2024
1 parent 0ba8cb4 commit 95a162b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions opentelemetry-sdk/benchmarks/logs/test_benchmark_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
)


def set_up_logging_handler(level):
def _set_up_logging_handler(level):
logger_provider = LoggerProvider()
exporter = InMemoryLogExporter()
processor = SimpleLogRecordProcessor(exporter=exporter)
Expand All @@ -18,21 +18,21 @@ def set_up_logging_handler(level):
return handler


def create_logger(handler, name):
def _create_logger(handler, name):
logger = logging.getLogger(name)
logger.addHandler(handler)
return logger


@pytest.mark.parametrize("num_loggers", [1, 10, 100, 1000, 10000])
@pytest.mark.parametrize("num_loggers", [1, 10, 100, 1000])
def test_simple_get_logger_different_names(benchmark, num_loggers):
handler = set_up_logging_handler(level=logging.DEBUG)
handler = _set_up_logging_handler(level=logging.DEBUG)
loggers = [
create_logger(handler, str(f"logger_{i}")) for i in range(num_loggers)
_create_logger(handler, str(f"logger_{i}")) for i in range(num_loggers)
]

def benchmark_get_logger():
for i in range(10000):
for i in range(1000):
loggers[i % num_loggers].warning("test message")

benchmark(benchmark_get_logger)

0 comments on commit 95a162b

Please sign in to comment.