jmerelo@ugr.es
Nothing exists; even if something exists, nothing can be known about it; and even if something can be known about it, knowledge about it can't be communicated to others.
def eliminate_whitespace_and_punctuation(text):
translator = str.maketrans(
'', '',
string.whitespace + string.punctuation + '«»“”‘’'
)
text = ''.join(filter(str.isalpha, text.translate(translator)))
return ''.join(
c for c in unicodedata.normalize('NFD', text)
if unicodedata.category(c) != 'Mn'
)
def calculate_frequency(text):
return Counter(text.lower())
| Symbol | Frequency | Symbol | Frequency |
|---|---|---|---|
| æ | 1 | p | 30449 |
| k | 3 | u | 36561 |
| y | 8 | d | 38203 |
| w | 16 | c | 48117 |
| j | 22 | s | 56020 |
| x | 139 | l | 57179 |
| z | 7803 | t | 62603 |
| q | 7997 | r | 67736 |
| b | 10036 | n | 74764 |
| f | 10811 | i | 98025 |
| h | 13831 | o | 99056 |
| g | 17556 | a | 118096 |
| v | 23585 | e | 123592 |
| m | 24233 |
PKG or "package",
includes all on-chip energy consumptionimport sys
from pyJoules.energy_meter import measure_energy
from sacrypt import process_text_v0
@measure_energy
def run_process(process_func, file_path):
process_func(file_path)
if __name__ == "__main__":
run_process(process_text_v0, file_path)
sudo make me a sandwich$ sudo ./.venv/bin/python bin/sacrypt-energy.py ../data/3romanzi.txt v1
begin timestamp : 1742670844.3934789; tag : run_process; duration : 0.08716917037963867; package_0 : 3239548.0; core_0 : 55554.0; nvidia_gpu_0 : 1150
| Command | Platforms | Attaches to command |
|---|---|---|
pinpoint | RAPL, IOReport for M1, others | Yes |
perf | Linux | No |
pumas | Mac | No |
$ sudo pinpoint sleep 1
Energy counter stats for 'sleep 1':
[interval: 50ms, before: 0ms, after: 0ms, delay: 0ms, runs: 1]
10.64 J nvml:nvidia_geforce_rtx_4070_super_0
22.17 J rapl:pkg
1.00109098 seconds time elapsed
pumas:
getting Watts
% Copilot rewrite this in
node.js
g++-14
-march=native
-std=c++2a
-Wall
chromosomes.cc generate_chromosomes.cc -o chromosomes
g++-14
-march=native
-Ofast
-std=c++17
-Wall
chromosomes.cc generate_chromosomes.cc -o chromosomes
def process_text_v0(file_path):
text = read_file(file_path)
cleaned_text = eliminate_whitespace_and_punctuation(text)
return calculate_frequency(cleaned_text)
def process_text_v1(file_path):
with open(file_path, 'r', encoding='utf-8') as file:
frequency = Counter(chain.from_iterable(line.lower() for line in file))
for symbol in list(frequency.keys()):
if not symbol.isalpha():
del frequency[symbol]
return frequency