Skip to content

Commit

Permalink
even more perf, update benchmark numbers
Browse files Browse the repository at this point in the history
Signed-off-by: martinvuyk <[email protected]>
  • Loading branch information
martinvuyk committed Dec 20, 2024
1 parent 954d39d commit a77d64d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions stdlib/benchmarks/collections/bench_string.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ===----------------------------------------------------------------------=== #
# RUN: %mojo-no-debug %s -t
# RUN: %mojo-no-debug %s
# NOTE: to test changes on the current branch using run-benchmarks.sh, remove
# the -t flag. Remember to replace it again before pushing any code.

Expand All @@ -23,6 +23,7 @@ from random import random_si64, seed
from benchmark import Bench, BenchConfig, Bencher, BenchId, Unit, keep, run

from utils._utf8_validation import _is_valid_utf8
from utils import StringSlice


# ===-----------------------------------------------------------------------===#
Expand Down Expand Up @@ -111,7 +112,7 @@ fn bench_string_split[
@always_inline
@parameter
fn call_fn() raises:
var res: List[String]
var res: List[StringSlice[__origin_of(items)]]

@parameter
if sequence:
Expand Down Expand Up @@ -237,7 +238,7 @@ def main():
)
alias old_chars = ("a", "ó", "ل", "и", "")
alias new_chars = ("A", "Ó", "ل", "И", "")
alias lengths = (10, 30, 50, 100, 1000, 10_000, 100_000, 1_000_000)
alias lengths = (1_000_000,)
"""At an average 5 letters per word and 300 words per page
(in the English language):
Expand Down
6 changes: 3 additions & 3 deletions stdlib/src/utils/string_slice.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -1358,11 +1358,11 @@ fn _split[
# FIXME(#3526): use str_span and sep_span
rhs = src_str.find(sep, lhs)
# if not found go to the end
rhs += int(rhs == -1) * (str_byte_len + 1)
rhs += -int(rhs == -1) & (str_byte_len + 1)

@parameter
if has_maxsplit:
rhs += int(items == maxsplit) * (str_byte_len - rhs)
rhs += -int(items == maxsplit) & (str_byte_len - rhs)
items += 1

output.append(S(ptr=ptr + lhs, length=rhs - lhs))
Expand Down Expand Up @@ -1415,7 +1415,7 @@ fn _split[

@parameter
if has_maxsplit:
rhs += int(items == maxsplit) * (str_byte_len - rhs)
rhs += -int(items == maxsplit) & (str_byte_len - rhs)
items += 1

output.append(S(ptr=ptr + lhs, length=rhs - lhs))
Expand Down

0 comments on commit a77d64d

Please sign in to comment.