diff --git a/nuitka-standalone-executable/cpu_benchmark.py b/nuitka-standalone-executable/cpu_benchmark.py new file mode 100644 index 0000000000..170d2b844f --- /dev/null +++ b/nuitka-standalone-executable/cpu_benchmark.py @@ -0,0 +1,11 @@ +import math +import time + +start = time.perf_counter() +total = 0.0 +for i in range(20_000_000): + total += math.sqrt(i) +elapsed = time.perf_counter() - start + +print(f"Result: {total}") +print(f"Time: {elapsed:.3f}s") diff --git a/nuitka-standalone-executable/sample.txt b/nuitka-standalone-executable/sample.txt new file mode 100644 index 0000000000..37db2cd82c --- /dev/null +++ b/nuitka-standalone-executable/sample.txt @@ -0,0 +1,5 @@ +Python is a popular programming language. Python is easy to learn, and Python +is also powerful enough for real projects. Many developers choose Python for +web development, data science, and automation. Python code is often easy to +read, which is one reason Python remains popular among beginners and +experienced developers alike. diff --git a/nuitka-standalone-executable/wordcount.py b/nuitka-standalone-executable/wordcount.py new file mode 100644 index 0000000000..04547108f1 --- /dev/null +++ b/nuitka-standalone-executable/wordcount.py @@ -0,0 +1,12 @@ +from argparse import ArgumentParser +from collections import Counter +from pathlib import Path + +parser = ArgumentParser(description="Show the most common words in a text file.") +parser.add_argument("file", type=Path) +parser.add_argument("-n", "--top", type=int, default=5) +args = parser.parse_args() + +words = args.file.read_text(encoding="utf-8").lower().split() +for word, count in Counter(words).most_common(args.top): + print(f"{word}: {count}")