instance_id stringlengths 17 47 | repo stringlengths 9 36 | image_name stringlengths 51 78 | base_commit stringlengths 40 40 | setup_patch stringlengths 421 4.69k | patch stringlengths 421 4.69k | workload stringlengths 294 1.99k | covering_tests listlengths 3 399 | test_cmd stringclasses 1
value | rebuild_cmd stringclasses 1
value | problem_statement stringlengths 526 939 | api stringlengths 10 95 | clean_mean float64 0.2 7.42 | regressed_mean float64 0.89 55.2 | slowdown float64 3.01 135 | source stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Cog-Creators__Red-DiscordBot.perf_0 | Cog-Creators/Red-DiscordBot | jyangballin/swesmith.x86_64.cog-creators_1776_red-discordbot.33e0eac7 | bc9ec7631756184f7405c0e1c443c8c57eb269d2 | diff --git a/redbot/core/utils/__init__.py b/redbot/core/utils/__init__.py
index dc3687f..fca043c 100644
--- a/redbot/core/utils/__init__.py
+++ b/redbot/core/utils/__init__.py
@@ -70,7 +70,11 @@ def deduplicate_iterables(*iterables):
were first encountered.
"""
# dict insertion order is guaranteed to be... | diff --git b/redbot/core/utils/__init__.py a/redbot/core/utils/__init__.py
index fca043c..dc3687f 100644
--- b/redbot/core/utils/__init__.py
+++ a/redbot/core/utils/__init__.py
@@ -70,11 +70,7 @@ def deduplicate_iterables(*iterables):
were first encountered.
"""
# dict insertion order is guaranteed to be... | import random
import statistics
import timeit
from redbot.core.utils import deduplicate_iterables
random.seed(20240521)
first = [random.randrange(400) for _ in range(120)]
second = [random.randrange(400) for _ in range(120)]
third = [random.randrange(400) for _ in range(60)]
# warm up
deduplicate_iterables(first, se... | [
"tests/core/test_utils.py::test_bounded_gather",
"tests/core/test_utils.py::test_bounded_gather_iter",
"tests/core/test_utils.py::test_deduplicate_iterables",
"tests/core/test_utils.py::test_normalize_smartquotes",
"tests/core/test_utils.py::test_pagify[@everyone",
"tests/core/test_utils.py::test_pagify[I... | python -m pytest -q -rA -p no:cacheprovider | I have a helper that merges a few lists of role/user IDs together while keeping the first-seen order, and I use the utility Red exposes for that in a loop that runs for every guild on every command invocation. With only a couple of hundred IDs coming from two or three lists, each call takes hundreds of microseconds, wh... | redbot.core.utils.deduplicate_iterables | 0.95981 | 16.176191 | 16.853534 | perf-pool-swesmith | |
Cog-Creators__Red-DiscordBot.perf_3 | Cog-Creators/Red-DiscordBot | jyangballin/swesmith.x86_64.cog-creators_1776_red-discordbot.33e0eac7 | bc9ec7631756184f7405c0e1c443c8c57eb269d2 | diff --git a/redbot/core/utils/chat_formatting.py b/redbot/core/utils/chat_formatting.py
index 9a96ae3..bcb72a5 100644
--- a/redbot/core/utils/chat_formatting.py
+++ b/redbot/core/utils/chat_formatting.py
@@ -486,8 +486,20 @@ def escape(text: str, *, mass_mentions: bool = False, formatting: bool = False)
"""
... | diff --git b/redbot/core/utils/chat_formatting.py a/redbot/core/utils/chat_formatting.py
index bcb72a5..9a96ae3 100644
--- b/redbot/core/utils/chat_formatting.py
+++ a/redbot/core/utils/chat_formatting.py
@@ -486,20 +486,8 @@ def escape(text: str, *, mass_mentions: bool = False, formatting: bool = False)
"""
... | import statistics
import timeit
from redbot.core.utils.chat_formatting import escape
text = "Hello @everyone and @here, please read this notice " + "content " * 6
# warm up
escape(text, mass_mentions=True)
N = 800000
results = timeit.repeat(lambda: escape(text, mass_mentions=True), number=N, repeat=5)
print(f"Mean:... | [
"tests/core/test_utils.py::test_bounded_gather",
"tests/core/test_utils.py::test_bounded_gather_iter",
"tests/core/test_utils.py::test_deduplicate_iterables",
"tests/core/test_utils.py::test_normalize_smartquotes",
"tests/core/test_utils.py::test_pagify[@everyone",
"tests/core/test_utils.py::test_pagify[I... | python -m pytest -q -rA -p no:cacheprovider | I sanitize user-provided strings with Red's escape helper (mass mentions enabled) before echoing them back; my cog does this for every row of a leaderboard, so it happens hundreds of thousands of times per refresh. Each call on a short ~100 character line now costs tens of microseconds instead of being basically free, ... | redbot.core.utils.chat_formatting.escape | 0.576705 | 25.965209 | 45.023417 | perf-pool-swesmith | |
Instagram__MonkeyType.perf_0 | Instagram/MonkeyType | jyangballin/swesmith.x86_64.instagram_1776_monkeytype.70c3acf6 | 810d9de4f99bb45a9b404a943bb2c9e54d578b16 | diff --git a/monkeytype/typing.py b/monkeytype/typing.py
index 507732b..45333a6 100644
--- a/monkeytype/typing.py
+++ b/monkeytype/typing.py
@@ -553,13 +553,15 @@ class RewriteMostSpecificCommonBase(TypeRewriter):
"""
klasses = union.__args__
- all_bases = []
-
- for klass in klasses:
... | diff --git b/monkeytype/typing.py a/monkeytype/typing.py
index 45333a6..507732b 100644
--- b/monkeytype/typing.py
+++ a/monkeytype/typing.py
@@ -553,15 +553,13 @@ class RewriteMostSpecificCommonBase(TypeRewriter):
"""
klasses = union.__args__
- common_bases = self._compute_bases(klasses[0])
-... | import timeit
from typing import Union
from monkeytype.typing import RewriteMostSpecificCommonBase
def build_leaves(common_depth=40, branches=20, leaf_depth=10):
cls = type("Root", (object,), {})
for i in range(common_depth):
cls = type("Mid%d" % i, (cls,), {})
leaves = []
for j in range(bran... | [
"tests/test_typing.py::TestGetType::test_builtin_types[1-int]",
"tests/test_typing.py::TestGetType::test_builtin_types[1.1-float]",
"tests/test_typing.py::TestGetType::test_builtin_types[<lambda>-Callable]",
"tests/test_typing.py::TestGetType::test_builtin_types[Dummy-Type]",
"tests/test_typing.py::TestGetT... | python -m pytest -q -rA -p no:cacheprovider | I'm using the "most specific common base" union rewriting on unions of model classes coming from a fairly deep class hierarchy (our ORM base chain is ~50 classes deep and I typically have 15-25 sibling subclasses in a single union). Rewriting a single union takes close to a millisecond, and since this happens for a lot... | monkeytype.typing.RewriteMostSpecificCommonBase.rewrite | 0.510707 | 5.243981 | 10.268086 | perf-pool-swesmith | |
Instagram__MonkeyType.perf_1 | Instagram/MonkeyType | jyangballin/swesmith.x86_64.instagram_1776_monkeytype.70c3acf6 | 810d9de4f99bb45a9b404a943bb2c9e54d578b16 | diff --git a/monkeytype/tracing.py b/monkeytype/tracing.py
index 1360d08..18b865e 100644
--- a/monkeytype/tracing.py
+++ b/monkeytype/tracing.py
@@ -218,9 +218,9 @@ class CallTracer:
def _get_func(self, frame: FrameType) -> Optional[Callable[..., Any]]:
code = frame.f_code
- if code not in self.c... | diff --git b/monkeytype/tracing.py a/monkeytype/tracing.py
index 18b865e..1360d08 100644
--- b/monkeytype/tracing.py
+++ a/monkeytype/tracing.py
@@ -218,9 +218,9 @@ class CallTracer:
def _get_func(self, frame: FrameType) -> Optional[Callable[..., Any]]:
code = frame.f_code
- func = get_func(frame... | import timeit
from monkeytype.tracing import CallTraceLogger, trace_calls
class NullLogger(CallTraceLogger):
def log(self, trace):
pass
def make_obj(depth=60):
def target(self, x):
return x + 1
cls = type("C0", (object,), {"target": target})
for i in range(1, depth):
cls = ... | [
"tests/test_tracing.py::TestGetFunc::test_get_func[frame0-a_static_method]",
"tests/test_tracing.py::TestGetFunc::test_get_func[frame1-a_class_method]",
"tests/test_tracing.py::TestGetFunc::test_get_func[frame2-an_instance_method]",
"tests/test_tracing.py::TestGetFunc::test_get_func[frame3-a_module_function]"... | python -m pytest -q -rA -p no:cacheprovider | Running my test suite under MonkeyType tracing is much slower than I'd expect. The hot spot is a method defined on a base class of a fairly deep class hierarchy (about 60 levels of single inheritance), which gets called hundreds of thousands of times. Tracing the same method over and over seems to redo the same expensi... | monkeytype.tracing.CallTracer._get_func | 0.538628 | 9.124814 | 16.940846 | perf-pool-swesmith | |
Instagram__MonkeyType.perf_2 | Instagram/MonkeyType | jyangballin/swesmith.x86_64.instagram_1776_monkeytype.70c3acf6 | 810d9de4f99bb45a9b404a943bb2c9e54d578b16 | diff --git a/monkeytype/typing.py b/monkeytype/typing.py
index 507732b..a4a8bfc 100644
--- a/monkeytype/typing.py
+++ b/monkeytype/typing.py
@@ -342,7 +342,14 @@ class GenericTypeRewriter(Generic[T], ABC):
typname = name_of_generic(typ)
else:
typname = getattr(typ, "__name__", None)
-... | diff --git b/monkeytype/typing.py a/monkeytype/typing.py
index a4a8bfc..507732b 100644
--- b/monkeytype/typing.py
+++ a/monkeytype/typing.py
@@ -342,14 +342,7 @@ class GenericTypeRewriter(Generic[T], ABC):
typname = name_of_generic(typ)
else:
typname = getattr(typ, "__name__", None)
-... | import timeit
from typing import Dict, List, Optional, Set, Tuple, Union
from monkeytype.stubs import render_annotation
anno = Dict[
str,
List[
Tuple[
int,
Optional[str],
Dict[str, Set[int]],
Union[int, str, float],
List[Tuple[str, Optional[i... | [
"tests/test_stubs.py::TestAttributeStub::test_simple_attribute[stub0-",
"tests/test_stubs.py::TestAttributeStub::test_simple_attribute[stub1-",
"tests/test_stubs.py::TestBuildModuleStubs::test_build_module_stubs",
"tests/test_stubs.py::TestBuildModuleStubs::test_build_module_stubs_typed_dict_parameter",
"te... | python -m pytest -q -rA -p no:cacheprovider | Rendering annotations for stubs got noticeably sluggish for us. We generate stubs for a module with a lot of functions whose arguments have moderately nested generic annotations (dicts of lists of tuples containing unions and optionals), and rendering a single annotation costs hundreds of microseconds, which adds up to... | monkeytype.typing.GenericTypeRewriter.rewrite | 0.33485 | 2.48583 | 7.423722 | perf-pool-swesmith | |
Instagram__MonkeyType.perf_3 | Instagram/MonkeyType | jyangballin/swesmith.x86_64.instagram_1776_monkeytype.70c3acf6 | 810d9de4f99bb45a9b404a943bb2c9e54d578b16 | diff --git a/monkeytype/cli.py b/monkeytype/cli.py
index 990079d..da570e1 100644
--- a/monkeytype/cli.py
+++ b/monkeytype/cli.py
@@ -102,8 +102,12 @@ def get_monkeytype_config(path: str) -> Config:
def display_sample_count(traces: List[CallTrace], stderr: IO[str]) -> None:
"""Print to stderr the number of trace... | diff --git b/monkeytype/cli.py a/monkeytype/cli.py
index da570e1..990079d 100644
--- b/monkeytype/cli.py
+++ a/monkeytype/cli.py
@@ -102,12 +102,8 @@ def get_monkeytype_config(path: str) -> Config:
def display_sample_count(traces: List[CallTrace], stderr: IO[str]) -> None:
"""Print to stderr the number of trace... | import io
import timeit
from monkeytype.cli import display_sample_count
from monkeytype.tracing import CallTrace
def f0(a):
return a
def f1(a):
return a
def f2(a):
return a
def f3(a):
return a
def f4(a):
return a
def f5(a):
return a
funcs = [f0, f1, f2, f3, f4, f5]
traces = [CallT... | [
"tests/test_cli.py::test_apply_stub_file_with_spaces",
"tests/test_cli.py::test_apply_stub_init",
"tests/test_cli.py::test_apply_stub_using_libcst",
"tests/test_cli.py::test_apply_stub_using_libcst__confine_new_imports_in_type_checking_block",
"tests/test_cli.py::test_apply_stub_using_libcst__exception",
... | python -m pytest -q -rA -p no:cacheprovider | When I run `monkeytype stub --sample-count` (or `apply --sample-count`) on a module with a few thousand stored traces, printing the per-function sample counts takes a surprisingly long time — several seconds of the CLI run are spent just producing those few lines of output. The number of lines printed is tiny (one per ... | monkeytype.cli.display_sample_count | 1.324241 | 7.952509 | 6.005333 | perf-pool-swesmith | |
Knio__dominate.perf_0 | Knio/dominate | jyangballin/swesmith.x86_64.knio_1776_dominate.9082227e | e8fb15dc30d653ed6fc46487a47add94cf805e1c | diff --git a/dominate/util.py b/dominate/util.py
index 1d730b3..833e010 100644
--- a/dominate/util.py
+++ b/dominate/util.py
@@ -61,12 +61,16 @@ def escape(data, quote=True): # stolen from std lib cgi
This is used to escape content that appears in the body of an HTML document
'''
- data = data.replace("&", "&... | diff --git b/dominate/util.py a/dominate/util.py
index 833e010..1d730b3 100644
--- b/dominate/util.py
+++ a/dominate/util.py
@@ -61,16 +61,12 @@ def escape(data, quote=True): # stolen from std lib cgi
This is used to escape content that appears in the body of an HTML document
'''
- # Table driven translation:... | import random
import statistics
import string
import timeit
from dominate.util import escape
random.seed(1234)
alphabet = string.ascii_letters + ' .,;:' + '<>&"'
snippets = [''.join(random.choice(alphabet) for _ in range(400))
for _ in range(2000)]
def run():
total = 0
for snippet in s... | [
"tests/test_dominate.py::test_version",
"tests/test_html.py::test_add",
"tests/test_html.py::test_arguments",
"tests/test_html.py::test_attribute_dashes",
"tests/test_html.py::test_attribute_none",
"tests/test_html.py::test_attributes",
"tests/test_html.py::test_boolean_attributes",
"tests/test_html.p... | python -m pytest -q -rA -p no:cacheprovider | We use dominate to build pages out of user supplied text, so every snippet gets run through dominate's html escaping helper before it goes into the document. On a page with a couple of thousand paragraphs of a few hundred characters each, the escaping alone now takes noticeably longer than everything else we do, and bu... | dominate.util.escape | 1.026926 | 13.999767 | 13.632699 | perf-pool-swesmith | |
Knio__dominate.perf_1 | Knio/dominate | jyangballin/swesmith.x86_64.knio_1776_dominate.9082227e | e8fb15dc30d653ed6fc46487a47add94cf805e1c | diff --git a/dominate/util.py b/dominate/util.py
index 1d730b3..1698e01 100644
--- a/dominate/util.py
+++ b/dominate/util.py
@@ -116,8 +116,19 @@ def url_escape(data):
def url_unescape(data):
- return re.sub('%([0-9a-fA-F]{2})',
- lambda m: unichr(int(m.group(1), 16)), data)
+ hex_digits = '0123456789abcdefAB... | diff --git b/dominate/util.py a/dominate/util.py
index 1698e01..1d730b3 100644
--- b/dominate/util.py
+++ a/dominate/util.py
@@ -116,19 +116,8 @@ def url_escape(data):
def url_unescape(data):
- hex_digits = '0123456789abcdefABCDEF'
- result = []
- i = 0
- while i < len(data):
- c = data[i]
- if c == '%' ... | import statistics
import timeit
from dominate.util import url_unescape
paths = []
for i in range(1000):
parts = ['segment%d-%d' % (i % 17, j) for j in range(10)]
paths.append('/'.join(parts) +
'?q=hello%20world&page=%2F' + str(i) + '&tag=caf%C3%A9')
def run():
total = 0
for path in ... | [
"tests/test_utils.py::test_container",
"tests/test_utils.py::test_context",
"tests/test_utils.py::test_include",
"tests/test_utils.py::test_system",
"tests/test_utils.py::test_unescape",
"tests/test_utils.py::test_url"
] | python -m pytest -q -rA -p no:cacheprovider | I'm using dominate's url unescaping helper to decode a batch of request paths/query strings (about a thousand strings of ~130 characters each, with only a handful of percent escapes in each). Decoding the batch takes tens of milliseconds, which is way more than I expected for such short strings, and it clearly scales w... | dominate.util.url_unescape | 0.670992 | 5.819844 | 8.673495 | perf-pool-swesmith | |
Knio__dominate.perf_3 | Knio/dominate | jyangballin/swesmith.x86_64.knio_1776_dominate.9082227e | e8fb15dc30d653ed6fc46487a47add94cf805e1c | diff --git a/dominate/dom_tag.py b/dominate/dom_tag.py
index 44ca8ba..3bf5422 100644
--- a/dominate/dom_tag.py
+++ b/dominate/dom_tag.py
@@ -216,13 +216,15 @@ class dom_tag(object):
if isinstance(obj, basestring):
obj = util.escape(obj)
- self.children.append(obj)
+ # rebind children to ... | diff --git b/dominate/dom_tag.py a/dominate/dom_tag.py
index 3bf5422..44ca8ba 100644
--- b/dominate/dom_tag.py
+++ a/dominate/dom_tag.py
@@ -216,15 +216,13 @@ class dom_tag(object):
if isinstance(obj, basestring):
obj = util.escape(obj)
- # rebind children to a new list so that callers holding ... | import statistics
import timeit
from dominate import tags
lines = ['%05d some log line with content here\n' % i for i in range(12000)]
def build():
block = tags.pre()
for line in lines:
block.add(line)
return block
build() # warm up
times = timeit.repeat(build, number=25, repeat=5)
print("M... | [
"tests/test_document.py::test_attributes",
"tests/test_document.py::test_bare_decorator",
"tests/test_document.py::test_containers",
"tests/test_document.py::test_decorator",
"tests/test_document.py::test_doc",
"tests/test_document.py::test_repr",
"tests/test_document.py::test_title",
"tests/test_dom_... | python -m pytest -q -rA -p no:cacheprovider | I dump log files into a page by creating a <pre> tag and appending each line to it in a loop. With around 12,000 lines this takes close to a third of a second just to assemble the tag (before any rendering happens), and the cost clearly grows quadratically: 6,000 lines take about a quarter of the time of 12,000. ... | dominate.dom_tag.dom_tag.add | 0.374804 | 7.083057 | 18.898048 | perf-pool-swesmith | |
Mimino666__langdetect.perf_0 | Mimino666/langdetect | jyangballin/swesmith.x86_64.mimino666_1776_langdetect.a1598f1a | fdd1c1b5222aa8a06136867324870e27a3c02d01 | diff --git a/langdetect/utils/unicode_block.py b/langdetect/utils/unicode_block.py
index f074189..eabd1f9 100644
--- a/langdetect/utils/unicode_block.py
+++ b/langdetect/utils/unicode_block.py
@@ -452,14 +452,9 @@ def unicode_block(ch):
# special case basic latin
if cp <= 0x7F:
return UNICODE_BASIC_L... | diff --git b/langdetect/utils/unicode_block.py a/langdetect/utils/unicode_block.py
index eabd1f9..f074189 100644
--- b/langdetect/utils/unicode_block.py
+++ a/langdetect/utils/unicode_block.py
@@ -452,9 +452,14 @@ def unicode_block(ch):
# special case basic latin
if cp <= 0x7F:
return UNICODE_BASIC_L... | import random
import statistics
import timeit
from langdetect.utils.unicode_block import unicode_block
random.seed(20240101)
RANGES = [
(0x4E00, 0x9FFF), # CJK Unified Ideographs
(0x3040, 0x309F), # Hiragana
(0x30A0, 0x30FF), # Katakana
(0xAC00, 0xD7AF), # Hangul Syllables
(0x0400, 0x04FF... | [
"langdetect/tests/test_detector.py::DetectorTest::test_detector1",
"langdetect/tests/test_detector.py::DetectorTest::test_detector2",
"langdetect/tests/test_detector.py::DetectorTest::test_detector3",
"langdetect/tests/test_detector.py::DetectorTest::test_detector4",
"langdetect/tests/test_detector.py::Dete... | python -m pytest -q -rA -p no:cacheprovider | I'm running language detection over a large batch of non-Latin documents (Chinese, Japanese, Korean, Cyrillic, Thai, Devanagari) and the per-character character-classification step has become the bottleneck. Classifying a few thousand non-ASCII characters takes several milliseconds, which adds up to minutes over my cor... | langdetect.utils.unicode_block.unicode_block | 0.721631 | 2.273396 | 3.150359 | perf-pool-swesmith | |
Mimino666__langdetect.perf_1 | Mimino666/langdetect | jyangballin/swesmith.x86_64.mimino666_1776_langdetect.a1598f1a | fdd1c1b5222aa8a06136867324870e27a3c02d01 | diff --git a/langdetect/utils/ngram.py b/langdetect/utils/ngram.py
index ee82e38..75c1e78 100644
--- a/langdetect/utils/ngram.py
+++ b/langdetect/utils/ngram.py
@@ -91,7 +91,13 @@ class NGram(object):
elif block in (UNICODE_BOPOMOFO, UNICODE_BOPOMOFO_EXTENDED):
ch = six.u('\u3105')
elif b... | diff --git b/langdetect/utils/ngram.py a/langdetect/utils/ngram.py
index 75c1e78..ee82e38 100644
--- b/langdetect/utils/ngram.py
+++ a/langdetect/utils/ngram.py
@@ -91,13 +91,7 @@ class NGram(object):
elif block in (UNICODE_BOPOMOFO, UNICODE_BOPOMOFO_EXTENDED):
ch = six.u('\u3105')
elif b... | import random
import statistics
import timeit
from langdetect.utils.ngram import NGram
random.seed(4242)
TEXT = ''.join(chr(random.randint(0x4E00, 0x9FFF)) for _ in range(2000))
def run():
for ch in TEXT:
NGram.normalize(ch)
run() # warm up
times = timeit.repeat(run, number=200, repeat=5)
print('Me... | [
"langdetect/tests/test_detector.py::DetectorTest::test_detector1",
"langdetect/tests/test_detector.py::DetectorTest::test_detector2",
"langdetect/tests/test_detector.py::DetectorTest::test_detector3",
"langdetect/tests/test_detector.py::DetectorTest::test_detector4",
"langdetect/tests/test_detector.py::Dete... | python -m pytest -q -rA -p no:cacheprovider | Normalizing Chinese/Japanese text before feature extraction is far slower than I expected. On a 2000-character Chinese document, normalizing character by character takes several tens of milliseconds; the same amount of Cyrillic or Latin text is roughly an order of magnitude faster. Since CJK is a big chunk of my corpus... | langdetect.utils.ngram.NGram.normalize | 0.742901 | 4.386085 | 5.904 | perf-pool-swesmith | |
Mimino666__langdetect.perf_2 | Mimino666/langdetect | jyangballin/swesmith.x86_64.mimino666_1776_langdetect.a1598f1a | fdd1c1b5222aa8a06136867324870e27a3c02d01 | diff --git a/langdetect/utils/ngram.py b/langdetect/utils/ngram.py
index ee82e38..1c908f1 100644
--- a/langdetect/utils/ngram.py
+++ b/langdetect/utils/ngram.py
@@ -101,11 +101,20 @@ class NGram(object):
'''Normalizer for Vietnamese.
Normalize Alphabet + Diacritical Mark(U+03xx) into U+1Exx.
... | diff --git b/langdetect/utils/ngram.py a/langdetect/utils/ngram.py
index 1c908f1..ee82e38 100644
--- b/langdetect/utils/ngram.py
+++ a/langdetect/utils/ngram.py
@@ -101,20 +101,11 @@ class NGram(object):
'''Normalizer for Vietnamese.
Normalize Alphabet + Diacritical Mark(U+03xx) into U+1Exx.
... | import random
import statistics
import timeit
from langdetect.utils.ngram import NGram
random.seed(31337)
LETTERS = 'abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ'
chars = []
while len(chars) < 20000:
if random.random() < 0.02:
chars.append(random.choice(NGram.TO_NORMALIZE_VI_CHARS))
... | [
"langdetect/tests/test_detector.py::DetectorTest::test_detector1",
"langdetect/tests/test_detector.py::DetectorTest::test_detector2",
"langdetect/tests/test_detector.py::DetectorTest::test_detector3",
"langdetect/tests/test_detector.py::DetectorTest::test_detector4",
"langdetect/tests/test_detector.py::Dete... | python -m pytest -q -rA -p no:cacheprovider | I feed fairly long documents (20-50 KB of text) into the detector and noticed that a big fraction of the total time is spent in the Vietnamese diacritic normalization pass that runs on every appended text, even for documents that contain almost no combining marks at all. For a 20k-character document with only a couple ... | langdetect.utils.ngram.NGram.normalize_vi | 0.692071 | 6.931504 | 10.015592 | perf-pool-swesmith | |
Mimino666__langdetect.perf_3 | Mimino666/langdetect | jyangballin/swesmith.x86_64.mimino666_1776_langdetect.a1598f1a | fdd1c1b5222aa8a06136867324870e27a3c02d01 | diff --git a/langdetect/detector_factory.py b/langdetect/detector_factory.py
index e026161..4dc2b58 100644
--- a/langdetect/detector_factory.py
+++ b/langdetect/detector_factory.py
@@ -83,9 +83,11 @@ class DetectorFactory(object):
raise LangDetectException(ErrorCode.DuplicateLangError, 'Duplicate the same ... | diff --git b/langdetect/detector_factory.py a/langdetect/detector_factory.py
index 4dc2b58..e026161 100644
--- b/langdetect/detector_factory.py
+++ a/langdetect/detector_factory.py
@@ -83,11 +83,9 @@ class DetectorFactory(object):
raise LangDetectException(ErrorCode.DuplicateLangError, 'Duplicate the same ... | import random
import statistics
import timeit
from langdetect.detector_factory import DetectorFactory
from langdetect.utils.lang_profile import LangProfile
random.seed(99)
ALPHABET = 'abcdefghijklmnopqrstuvwxyz'
words = set()
while len(words) < 800:
n = random.randint(1, 3)
words.add(''.join(random.choice(AL... | [
"langdetect/tests/test_detector.py::DetectorTest::test_detector1",
"langdetect/tests/test_detector.py::DetectorTest::test_detector2",
"langdetect/tests/test_detector.py::DetectorTest::test_detector3",
"langdetect/tests/test_detector.py::DetectorTest::test_detector4",
"langdetect/tests/test_detector.py::Dete... | python -m pytest -q -rA -p no:cacheprovider | Registering language profiles into a factory has become surprisingly expensive for me. I build my own profiles (a few hundred to a few thousand n-grams each) and add several of them to a factory at startup; adding three profiles with ~800 n-grams each takes tens of milliseconds, and the cost clearly grows super-linearl... | langdetect.detector_factory.DetectorFactory.add_profile | 0.365655 | 5.498859 | 15.038387 | perf-pool-swesmith | |
google__textfsm.perf_1 | google/textfsm | jyangballin/swesmith.x86_64.google_1776_textfsm.c31b6007 | b8d48ec31de6fcc701b3b1b2f5952831d90a8b09 | diff --git a/textfsm/texttable.py b/textfsm/texttable.py
index 5af6be6..04e839c 100755
--- a/textfsm/texttable.py
+++ b/textfsm/texttable.py
@@ -86,8 +86,13 @@ class Row(dict):
ret.append(self[col])
return ret
+ # Map the column names to their offset in the row.
+ index = {}
+ for i, key in e... | diff --git b/textfsm/texttable.py a/textfsm/texttable.py
index 04e839c..5af6be6 100755
--- b/textfsm/texttable.py
+++ a/textfsm/texttable.py
@@ -86,13 +86,8 @@ class Row(dict):
ret.append(self[col])
return ret
- # Map the column names to their offset in the row.
- index = {}
- for i, key in e... | import io
import random
import timeit
from textfsm import texttable
random.seed(1)
COLS = 60
ROWS = 120
lines = [','.join('col%d' % i for i in range(COLS))]
for r in range(ROWS):
lines.append(
','.join('v%d_%d' % (r, random.randint(1000, 9999)) for _ in range(COLS))
)
csv_data = '\n'.join(lines) + '\n'
t... | [
"tests/texttable_test.py::UnitTestRow::testHeader",
"tests/texttable_test.py::UnitTestRow::testIndex",
"tests/texttable_test.py::UnitTestRow::testRowBasicMethods",
"tests/texttable_test.py::UnitTestRow::testRowPublicMethods",
"tests/texttable_test.py::UnitTestRow::testSetValues",
"tests/texttable_test.py:... | python -m pytest -q -rA -p no:cacheprovider | I have a wide table (about 60 columns, a few hundred rows) built from CSV and I walk over every row pulling out fields by their column name, e.g. `row['ifname']`. A single full pass over the table costs tens of milliseconds, which feels wrong for what should just be a name-to-offset lookup per field; fetching a value b... | textfsm.texttable.Row.__getitem__ | 0.24828 | 3.322589 | 13.382446 | perf-pool-swesmith | |
erikrose__parsimonious.perf_0 | erikrose/parsimonious | jyangballin/swesmith.x86_64.erikrose_1776_parsimonious.0d3f5f93 | 4c817331415d1f5f78e2710ca314be1a62f1ad15 | diff --git a/parsimonious/expressions.py b/parsimonious/expressions.py
index a1cf40b..622a5c9 100644
--- a/parsimonious/expressions.py
+++ b/parsimonious/expressions.py
@@ -440,7 +440,8 @@ class Quantifier(Compound):
length = node.end - node.start
if len(children) >= self.min and length == 0: ... | diff --git b/parsimonious/expressions.py a/parsimonious/expressions.py
index 622a5c9..a1cf40b 100644
--- b/parsimonious/expressions.py
+++ a/parsimonious/expressions.py
@@ -440,8 +440,7 @@ class Quantifier(Compound):
length = node.end - node.start
if len(children) >= self.min and length == 0: ... | import timeit
from parsimonious.grammar import Grammar
grammar = Grammar(r'''
doc = entry*
entry = key "=" value ws
key = "alpha" / "beta" / "gamma" / "delta"
value = ~"[0-9a-f]{16}"
ws = ~"[ \n]*"
''')
keys = ['alpha', 'beta', 'gamma', 'delta']
parts = []
for i in range(4000):
parts.appen... | [
"parsimonious/tests/test_benchmarks.py::TestBenchmarks::test_call_vs_inline",
"parsimonious/tests/test_benchmarks.py::TestBenchmarks::test_lists_vs_dicts",
"parsimonious/tests/test_benchmarks.py::TestBenchmarks::test_startswith_vs_regex",
"parsimonious/tests/test_expressions.py::ErrorReportingTests::test_favo... | python -m pytest -q -rA -p no:cacheprovider | I use parsimonious to parse machine-generated config dumps: a grammar whose top level is basically `doc = entry*` over a few thousand `key=value` lines. For a small file (a few hundred entries) parsing is instant, but as the file grows the parse time grows much faster than the file does: 4000 entries takes well over a ... | parsimonious.grammar.Grammar.parse | 0.258475 | 3.915094 | 15.146906 | perf-pool-swesmith | |
erikrose__parsimonious.perf_2 | erikrose/parsimonious | jyangballin/swesmith.x86_64.erikrose_1776_parsimonious.0d3f5f93 | 4c817331415d1f5f78e2710ca314be1a62f1ad15 | diff --git a/parsimonious/expressions.py b/parsimonious/expressions.py
index a1cf40b..b5c0224 100644
--- a/parsimonious/expressions.py
+++ b/parsimonious/expressions.py
@@ -260,7 +260,8 @@ class Literal(Expression):
self.identity_tuple = (name, literal)
def _uncached_match(self, text, pos, cache, error)... | diff --git b/parsimonious/expressions.py a/parsimonious/expressions.py
index b5c0224..a1cf40b 100644
--- b/parsimonious/expressions.py
+++ a/parsimonious/expressions.py
@@ -260,8 +260,7 @@ class Literal(Expression):
self.identity_tuple = (name, literal)
def _uncached_match(self, text, pos, cache, error)... | import timeit
from parsimonious.grammar import Grammar
grammar = Grammar(r'''
doc = entry*
entry = key "=" value ws
key = "alpha" / "beta" / "gamma" / "delta"
value = ~"[0-9a-f]{16}"
ws = ~"[ \n]*"
''')
keys = ['alpha', 'beta', 'gamma', 'delta']
parts = []
for i in range(25000):
parts.appe... | [
"parsimonious/tests/test_benchmarks.py::TestBenchmarks::test_call_vs_inline",
"parsimonious/tests/test_benchmarks.py::TestBenchmarks::test_lists_vs_dicts",
"parsimonious/tests/test_benchmarks.py::TestBenchmarks::test_startswith_vs_regex",
"parsimonious/tests/test_expressions.py::ErrorReportingTests::test_favo... | python -m pytest -q -rA -p no:cacheprovider | I parse largish key/value dumps (a few hundred kilobytes, ~25k records) with a grammar that uses a handful of plain string alternatives for the record keys plus a couple of regexes. Parsing takes multiple seconds, and worse, it gets disproportionately slower as the file grows: doubling the file size roughly quadruples ... | parsimonious.grammar.Grammar.parse | 0.289136 | 1.399375 | 4.839845 | perf-pool-swesmith | |
erikrose__parsimonious.perf_3 | erikrose/parsimonious | jyangballin/swesmith.x86_64.erikrose_1776_parsimonious.0d3f5f93 | 4c817331415d1f5f78e2710ca314be1a62f1ad15 | diff --git a/parsimonious/nodes.py b/parsimonious/nodes.py
index 7839097..b7dac43 100644
--- a/parsimonious/nodes.py
+++ b/parsimonious/nodes.py
@@ -75,14 +75,14 @@ class Node(object):
# them all. Whoops.
def indent(text):
return '\n'.join((' ' + line) for line in text.splitlines())
- ... | diff --git b/parsimonious/nodes.py a/parsimonious/nodes.py
index b7dac43..7839097 100644
--- b/parsimonious/nodes.py
+++ a/parsimonious/nodes.py
@@ -75,14 +75,14 @@ class Node(object):
# them all. Whoops.
def indent(text):
return '\n'.join((' ' + line) for line in text.splitlines())
- ... | import timeit
from parsimonious.grammar import Grammar
grammar = Grammar(r'''
doc = word*
word = letters ws
letters = ~"[a-z]+"
ws = ~"[ \n]*"
''')
vocabulary = ['alpha', 'bravo', 'charlie', 'delta', 'echo', 'foxtrot']
parts = []
for i in range(10000):
parts.append(vocabulary[i % len(vocabular... | [
"parsimonious/tests/test_grammar.py::BootstrappingGrammarTests::test_quantifier",
"parsimonious/tests/test_grammar.py::BootstrappingGrammarTests::test_regex",
"parsimonious/tests/test_grammar.py::BootstrappingGrammarTests::test_spaceless_literal",
"parsimonious/tests/test_grammar.py::BootstrappingGrammarTests... | python -m pytest -q -rA -p no:cacheprovider | When debugging a grammar I dump the parse tree with `str(node)` (and I hit the same thing indirectly when a visitor raises and the error message embeds the tree). For a tree whose root has ~10k children this takes well over a second, and it gets much worse than linearly as I add more input: 5k children is roughly a qua... | parsimonious.nodes.Node.prettily | 0.275571 | 3.242508 | 11.7665 | perf-pool-swesmith | |
python-trio__trio.perf_0 | python-trio/trio | jyangballin/swesmith.x86_64.python-trio_1776_trio.cfbbe2c1 | 1d2401c79fa90d21ea9745a8f717046d1ff79514 | diff --git a/src/trio/_core/_run.py b/src/trio/_core/_run.py
index bfb38f4..c816513 100644
--- a/src/trio/_core/_run.py
+++ b/src/trio/_core/_run.py
@@ -283,7 +283,9 @@ class Deadlines:
def expire(self, now: float) -> bool:
did_something = False
- while self._heap and self._heap[0][0] <= now:
+ ... | diff --git b/src/trio/_core/_run.py a/src/trio/_core/_run.py
index c816513..bfb38f4 100644
--- b/src/trio/_core/_run.py
+++ a/src/trio/_core/_run.py
@@ -283,9 +283,7 @@ class Deadlines:
def expire(self, now: float) -> bool:
did_something = False
- # Look at the earliest deadline that is still reg... | import statistics
import timeit
from contextlib import ExitStack
import trio
NUM_SCOPES = 4000
NUM_CHECKPOINTS = 4000
async def main() -> None:
now = trio.current_time()
with ExitStack() as stack:
for i in range(NUM_SCOPES):
stack.enter_context(trio.move_on_at(now + 1000.0 + i))
... | [
"src/trio/_core/_tests/test_run.py::test_CancelScope_subclass",
"src/trio/_core/_tests/test_run.py::test_Cancelled_init",
"src/trio/_core/_tests/test_run.py::test_Cancelled_str",
"src/trio/_core/_tests/test_run.py::test_Cancelled_subclass",
"src/trio/_core/_tests/test_run.py::test_Nursery_init",
"src/trio... | python -m pytest -q -rA -p no:cacheprovider | I have a server-ish workload where each in-flight request holds its own timeout scope, so at any moment there are a few thousand live `trio.move_on_at`/`fail_after` scopes with far-future deadlines. Once the number of outstanding scopes grows into the thousands, plain `await trio.lowlevel.checkpoint()` (and therefore e... | trio.lowlevel.checkpoint (deadline expiry bookkeeping in the run loop) | 0.502963 | 4.42157 | 8.79105 | perf-pool-swesmith | |
python-trio__trio.perf_3 | python-trio/trio | jyangballin/swesmith.x86_64.python-trio_1776_trio.cfbbe2c1 | 1d2401c79fa90d21ea9745a8f717046d1ff79514 | diff --git a/src/trio/_sync.py b/src/trio/_sync.py
index ca37392..b56c4e2 100644
--- a/src/trio/_sync.py
+++ b/src/trio/_sync.py
@@ -302,7 +302,9 @@ class CapacityLimiter(AsyncContextManagerMixin):
tokens.
"""
- if borrower in self._borrowers:
+ # Make sure this borrower isn't al... | diff --git b/src/trio/_sync.py a/src/trio/_sync.py
index b56c4e2..ca37392 100644
--- b/src/trio/_sync.py
+++ a/src/trio/_sync.py
@@ -302,9 +302,7 @@ class CapacityLimiter(AsyncContextManagerMixin):
tokens.
"""
- # Make sure this borrower isn't already holding a token; compare
- #... | import statistics
import timeit
import trio
SIZE = 1000
async def main() -> None:
limiter = trio.CapacityLimiter(SIZE)
borrowers = [object() for _ in range(SIZE)]
for b in borrowers:
limiter.acquire_on_behalf_of_nowait(b)
for b in borrowers:
limiter.release_on_behalf_of(b)
def run(... | [
"src/trio/_tests/test_sync.py::test_CapacityLimiter",
"src/trio/_tests/test_sync.py::test_CapacityLimiter_change_total_tokens",
"src/trio/_tests/test_sync.py::test_CapacityLimiter_inf",
"src/trio/_tests/test_sync.py::test_CapacityLimiter_memleak_548",
"src/trio/_tests/test_sync.py::test_Condition",
"src/t... | python -m pytest -q -rA -p no:cacheprovider | I'm using a `trio.CapacityLimiter` with a large token count (about a thousand) and handing out tokens on behalf of my own connection objects via `acquire_on_behalf_of_nowait()`. As the number of tokens currently held grows, each additional acquire gets slower and slower — filling the limiter to capacity takes tens of m... | trio.CapacityLimiter.acquire_on_behalf_of_nowait | 0.282868 | 4.100634 | 14.496612 | perf-pool-swesmith | |
gawel__pyquery.perf_2 | gawel/pyquery | jyangballin/swesmith.x86_64.gawel_1776_pyquery.811cd048 | 610572bd9a288f3f8967a43bf0d3df257a6ee3be | diff --git a/pyquery/pyquery.py b/pyquery/pyquery.py
index 5b05681..a96a4c7 100644
--- a/pyquery/pyquery.py
+++ b/pyquery/pyquery.py
@@ -608,9 +608,9 @@ class PyQuery(list):
return self._filter_only(selector, self)
else:
elements = []
- args = getargspec(callback)
... | diff --git b/pyquery/pyquery.py a/pyquery/pyquery.py
index a96a4c7..5b05681 100644
--- b/pyquery/pyquery.py
+++ a/pyquery/pyquery.py
@@ -608,9 +608,9 @@ class PyQuery(list):
return self._filter_only(selector, self)
else:
elements = []
+ args = getargspec(callback)
... | import timeit
import statistics
from pyquery import PyQuery
parts = []
for i in range(3000):
parts.append('<p>item %d</p>' % i)
doc = PyQuery('<div>' + ''.join(parts) + '</div>')
sel = doc('p')
predicate = lambda i: i % 3 == 0 # noqa: E731
# warm up
sel.filter(predicate)
res = timeit.repeat(lambda: sel.filter(... | [
"tests/test_pyquery.py::TestAjax::test_serialize",
"tests/test_pyquery.py::TestAjax::test_serialize_array",
"tests/test_pyquery.py::TestAjax::test_serialize_dict",
"tests/test_pyquery.py::TestAjax::test_serialize_pairs_filter_controls",
"tests/test_pyquery.py::TestAjax::test_serialize_pairs_form_controls",
... | python -m pytest -q -rA -p no:cacheprovider | I filter selections with a Python predicate, e.g. `doc('p').filter(lambda i: i % 3 == 0)`, on selections of a few thousand elements. Even with a trivial predicate that just looks at the index, the call takes ~70 ms for 3000 elements, i.e. tens of microseconds per element, while calling my lambda 3000 times in a plain P... | pyquery.pyquery.PyQuery.filter | 0.326307 | 7.516159 | 23.033994 | perf-pool-swesmith | |
gawel__pyquery.perf_3 | gawel/pyquery | jyangballin/swesmith.x86_64.gawel_1776_pyquery.811cd048 | 610572bd9a288f3f8967a43bf0d3df257a6ee3be | diff --git a/pyquery/text.py b/pyquery/text.py
index 9d68c20..12b2ece 100644
--- a/pyquery/text.py
+++ b/pyquery/text.py
@@ -17,11 +17,22 @@ SEPARATORS = {'br'}
WHITESPACE_RE = re.compile('[\x20\x09\x0C\u200B\x0A\x0D]+')
+HTML_WHITESPACE = '\x20\x09\x0C\u200B\x0A\x0D'
+
+
def squash_html_whitespace(text):
# ... | diff --git b/pyquery/text.py a/pyquery/text.py
index 12b2ece..9d68c20 100644
--- b/pyquery/text.py
+++ a/pyquery/text.py
@@ -17,22 +17,11 @@ SEPARATORS = {'br'}
WHITESPACE_RE = re.compile('[\x20\x09\x0C\u200B\x0A\x0D]+')
-HTML_WHITESPACE = '\x20\x09\x0C\u200B\x0A\x0D'
-
-
def squash_html_whitespace(text):
# ... | import random
import timeit
import statistics
from pyquery import PyQuery
random.seed(0)
paragraphs = []
for _ in range(200):
tokens = ['%040x' % random.getrandbits(160) for _ in range(40)]
paragraphs.append('<p>' + ' '.join(tokens) + '</p>')
doc = PyQuery('<div>' + ''.join(paragraphs) + '</div>')
# warm up
d... | [
"tests/test_pyquery.py::TestAjax::test_serialize",
"tests/test_pyquery.py::TestAjax::test_serialize_array",
"tests/test_pyquery.py::TestAjax::test_serialize_dict",
"tests/test_pyquery.py::TestAjax::test_serialize_pairs_filter_controls",
"tests/test_pyquery.py::TestAjax::test_serialize_pairs_form_controls",
... | python -m pytest -q -rA -p no:cacheprovider | I extract the visible text of fairly large documents with `PyQuery(html).text()` — a container with a couple hundred paragraphs, a few hundred kilobytes of text in total. This takes about 40 ms per document, which is much slower than I expected: serializing the same document back to HTML, or even parsing it in the firs... | pyquery.pyquery.PyQuery.text | 1.74477 | 6.718245 | 3.850505 | perf-pool-swesmith | |
borntyping__python-colorlog.perf_0 | borntyping/python-colorlog | jyangballin/swesmith.x86_64.borntyping_1776_python-colorlog.dfa10f59 | 4cba637107c6a8431b9f95d48b67677bce860305 | diff --git a/colorlog/formatter.py b/colorlog/formatter.py
index f011ca2..76fe832 100644
--- a/colorlog/formatter.py
+++ b/colorlog/formatter.py
@@ -49,8 +49,19 @@ class ColoredRecord:
"""
def __init__(self, record: logging.LogRecord, escapes: EscapeCodes) -> None:
- self.__dict__.update(record.__dic... | diff --git b/colorlog/formatter.py a/colorlog/formatter.py
index 76fe832..f011ca2 100644
--- b/colorlog/formatter.py
+++ a/colorlog/formatter.py
@@ -49,19 +49,8 @@ class ColoredRecord:
"""
def __init__(self, record: logging.LogRecord, escapes: EscapeCodes) -> None:
- # Merge the record attributes wit... | import logging
import statistics
import timeit
import colorlog
formatter = colorlog.ColoredFormatter(
"%(log_color)s%(levelname)-8s%(reset)s %(name)s: %(message)s",
force_color=True,
)
LEVELS = [logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL]
records = []
for i in range(50):
... | [
"colorlog/tests/test_colorlog.py::TestLevelFormatter::test_level_formatter",
"colorlog/tests/test_colorlog.py::test_braces_style",
"colorlog/tests/test_colorlog.py::test_colored_formatter",
"colorlog/tests/test_colorlog.py::test_custom_colors",
"colorlog/tests/test_colorlog.py::test_no_reset",
"colorlog/t... | python -m pytest -q -rA -p no:cacheprovider | We use colorlog for a service that emits a fairly high volume of log lines (tens of thousands of records a minute across a handful of loggers). After upgrading, formatting a single record with a ColoredFormatter has become noticeably expensive: a tight loop that formats 50 pre-built LogRecords takes several millisecond... | colorlog.ColoredFormatter.format | 1.529539 | 8.775855 | 5.737583 | perf-pool-swesmith | |
borntyping__python-colorlog.perf_1 | borntyping/python-colorlog | jyangballin/swesmith.x86_64.borntyping_1776_python-colorlog.dfa10f59 | 4cba637107c6a8431b9f95d48b67677bce860305 | diff --git a/colorlog/formatter.py b/colorlog/formatter.py
index f011ca2..d55b3f7 100644
--- a/colorlog/formatter.py
+++ b/colorlog/formatter.py
@@ -140,7 +140,12 @@ class ColoredFormatter(logging.Formatter):
If _blank_escape_codes() returns True, all values will be an empty string.
"""
- cod... | diff --git b/colorlog/formatter.py a/colorlog/formatter.py
index d55b3f7..f011ca2 100644
--- b/colorlog/formatter.py
+++ a/colorlog/formatter.py
@@ -140,12 +140,7 @@ class ColoredFormatter(logging.Formatter):
If _blank_escape_codes() returns True, all values will be an empty string.
"""
- # R... | import logging
import statistics
import timeit
import colorlog
formatter = colorlog.ColoredFormatter(
"%(log_color)s%(levelname)-8s%(reset)s %(name)s: %(message)s",
force_color=True,
)
LEVELS = [logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL]
records = []
for i in range(50):
... | [
"colorlog/tests/test_colorlog.py::TestLevelFormatter::test_level_formatter",
"colorlog/tests/test_colorlog.py::test_braces_style",
"colorlog/tests/test_colorlog.py::test_colored_formatter",
"colorlog/tests/test_colorlog.py::test_custom_colors",
"colorlog/tests/test_colorlog.py::test_no_reset",
"colorlog/t... | python -m pytest -q -rA -p no:cacheprovider | Colorized logging is dominating the runtime of our batch jobs. Formatting a batch of 50 already-constructed LogRecords with a `ColoredFormatter` (simple `%`-style format with `log_color`/`reset`) takes tens of milliseconds, i.e. hundreds of microseconds per record, while the stdlib formatter handles the same records in... | colorlog.ColoredFormatter.format | 0.760423 | 12.525091 | 16.471218 | perf-pool-swesmith | |
borntyping__python-colorlog.perf_2 | borntyping/python-colorlog | jyangballin/swesmith.x86_64.borntyping_1776_python-colorlog.dfa10f59 | 4cba637107c6a8431b9f95d48b67677bce860305 | diff --git a/colorlog/formatter.py b/colorlog/formatter.py
index f011ca2..178046d 100644
--- a/colorlog/formatter.py
+++ b/colorlog/formatter.py
@@ -170,10 +170,21 @@ class ColoredFormatter(logging.Formatter):
"""Add a reset code to the end of the message, if it's not already there."""
reset_escape_co... | diff --git b/colorlog/formatter.py a/colorlog/formatter.py
index 178046d..f011ca2 100644
--- b/colorlog/formatter.py
+++ a/colorlog/formatter.py
@@ -170,21 +170,10 @@ class ColoredFormatter(logging.Formatter):
"""Add a reset code to the end of the message, if it's not already there."""
reset_escape_co... | import logging
import statistics
import timeit
import colorlog
formatter = colorlog.ColoredFormatter(
"%(log_color)s%(levelname)-8s %(name)s: %(message)s",
force_color=True,
)
LEVELS = [logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL]
records = []
for i in range(50):
record... | [
"colorlog/tests/test_colorlog.py::TestLevelFormatter::test_level_formatter",
"colorlog/tests/test_colorlog.py::test_braces_style",
"colorlog/tests/test_colorlog.py::test_colored_formatter",
"colorlog/tests/test_colorlog.py::test_custom_colors",
"colorlog/tests/test_colorlog.py::test_no_reset",
"colorlog/t... | python -m pytest -q -rA -p no:cacheprovider | I'm benchmarking our logging pipeline and `ColoredFormatter.format()` is much slower than I expected. With a plain `%`-style format string and colour forced on, formatting 50 records takes several milliseconds — roughly 100µs per record — whereas the stdlib formatter does the same work in a few microseconds. The cost i... | colorlog.ColoredFormatter.format | 1.51967 | 7.401843 | 4.87069 | perf-pool-swesmith | |
borntyping__python-colorlog.perf_3 | borntyping/python-colorlog | jyangballin/swesmith.x86_64.borntyping_1776_python-colorlog.dfa10f59 | 4cba637107c6a8431b9f95d48b67677bce860305 | diff --git a/colorlog/escape_codes.py b/colorlog/escape_codes.py
index 185b947..08747bd 100644
--- a/colorlog/escape_codes.py
+++ b/colorlog/escape_codes.py
@@ -102,4 +102,13 @@ for code in range(256):
def parse_colors(string: str) -> str:
"""Return escape codes from a color sequence string."""
- return "".j... | diff --git b/colorlog/escape_codes.py a/colorlog/escape_codes.py
index 08747bd..185b947 100644
--- b/colorlog/escape_codes.py
+++ a/colorlog/escape_codes.py
@@ -102,13 +102,4 @@ for code in range(256):
def parse_colors(string: str) -> str:
"""Return escape codes from a color sequence string."""
- names = [na... | import statistics
import timeit
from colorlog.escape_codes import parse_colors
SEQUENCES = [
"bold_red",
"green",
"fg_bold_yellow",
"bg_light_blue",
"fg_200",
"bg_17",
"thin_white",
"reset",
"bold,fg_cyan",
"fg_bold_white,bg_red",
]
def run():
for sequence in SEQUENCES:
... | [
"colorlog/tests/test_colorlog.py::TestLevelFormatter::test_level_formatter",
"colorlog/tests/test_colorlog.py::test_braces_style",
"colorlog/tests/test_colorlog.py::test_colored_formatter",
"colorlog/tests/test_colorlog.py::test_custom_colors",
"colorlog/tests/test_colorlog.py::test_no_reset",
"colorlog/t... | python -m pytest -q -rA -p no:cacheprovider | We build our own colour theme on top of colorlog and resolve colour sequences (things like `"fg_bold_yellow"`, `"bg_light_blue"`, `"fg_200"`, `"bold,fg_cyan"`) at runtime, several times per rendered line. Resolving a single sequence now takes on the order of 10-20µs, which is thousands of times more than a dictionary l... | colorlog.escape_codes.parse_colors | 0.341145 | 3.927111 | 11.511566 | perf-pool-swesmith | |
arrow-py__arrow.perf_0 | arrow-py/arrow | jyangballin/swesmith.x86_64.arrow-py_1776_arrow.1d70d009 | e2ffa95da9e1b81ea793a8cd910bbf25593b1971 | diff --git a/arrow/arrow.py b/arrow/arrow.py
index 9d1f5e3..ebe156e 100644
--- a/arrow/arrow.py
+++ b/arrow/arrow.py
@@ -1500,9 +1500,11 @@ class Arrow:
include_start = bounds[0] == "["
include_end = bounds[1] == "]"
- target_ts = self.float_timestamp
- start_ts = start.float_timestamp... | diff --git b/arrow/arrow.py a/arrow/arrow.py
index ebe156e..9d1f5e3 100644
--- b/arrow/arrow.py
+++ a/arrow/arrow.py
@@ -1500,11 +1500,9 @@ class Arrow:
include_start = bounds[0] == "["
include_end = bounds[1] == "]"
- # normalize each endpoint to UTC first so that the comparison is
- ... | import statistics
import timeit
import arrow
BASE = 1600000000
targets = [arrow.get(BASE + i * 60) for i in range(500)]
starts = [arrow.get(BASE + i * 60 - 30) for i in range(500)]
ends = [arrow.get(BASE + i * 60 + 30) for i in range(500)]
def run():
count = 0
for target, start, end in zip(targets, starts,... | [
"tests/test_arrow.py::TestArrowAttribute::test_float_timestamp",
"tests/test_arrow.py::TestArrowAttribute::test_getattr_ambiguous",
"tests/test_arrow.py::TestArrowAttribute::test_getattr_base",
"tests/test_arrow.py::TestArrowAttribute::test_getattr_dt_value",
"tests/test_arrow.py::TestArrowAttribute::test_g... | python -m pytest -q -rA -p no:cacheprovider | I have a scheduling service that filters events by checking whether each event timestamp falls inside a candidate window, so I end up calling `is_between` a few hundred thousand times per request batch. This is conceptually just three instant comparisons, but profiling shows it is by far the hottest thing in my code: f... | arrow.arrow.Arrow.is_between | 0.485934 | 1.542139 | 3.173553 | perf-pool-swesmith |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 19