<jupyter_start><jupyter_text>Julia sets<jupyter_code>import matplotlib.pyplot as plt
%matplotlib inline
import numpy as np
from pathlib import Path
import psutil
import sh
import time<jupyter_output><empty_output><jupyter_text>Compile and build the application.<jupyter_code>application = 'julia.exe'
_ = sh.gfortran('-O2', '-fopenmp', '-o', application, 'julia_omp.f90', '-lm')<jupyter_output><empty_output><jupyter_text>Since the current working directory is not in the `PATH` environment variable, and the executable has a `.` in its name, a command has to be created.<jupyter_code>julia = sh.Command(Path.cwd() / application)<jupyter_output><empty_output><jupyter_text>Execute the application in the background and monitor user and system time and memory (RSS, Resident Set Size).<jupyter_code>computation = julia('2000', _bg=True)
process = psutil.Process(pid=computation.pid)
while psutil.pid_exists(process.pid):
    times = process.cpu_times()
    memory = process.memory_info()
    print(f'user: {times.user}, sys: {times.system}, CPU: {process.cpu_percent()} %, rss: {memory.rss} bytes')
    time.sleep(0.5)<jupyter_output>user: 0.0, sys: 0.0, CPU: 0.0 %, rss: 12972032 bytes
user: 0.34, sys: 0.04, CPU: 75.1 %, rss: 82718720 bytes
user: 0.75, sys: 0.04, CPU: 81.7 %, rss: 82718720 bytes
user: 1.16, sys: 0.05, CPU: 83.8 %, rss: 82718720 bytes
user: 1.53, sys: 0.05, CPU: 73.8 %, rss: 82718720 bytes
user: 1.9, sys: 0.05, CPU: 73.8 %, rss: 82718720 bytes
user: 2.25, sys: 0.05, CPU: 69.8 %, rss: 82718720 bytes
user: 2.57, sys: 0.06, CPU: 65.8 %, rss: 82718720 bytes
user: 2.95, sys: 0.08, CPU: 79.8 %, rss: 82718720 bytes
user: 3.26, sys: 0.08, CPU: 61.7 %, rss: 0 bytes<jupyter_text>Just for fun, plot the output.<jupyter_code>data_file = 'julia.txt'
data = np.genfromtxt(data_file)
_ = plt.imshow(data)<jupyter_output><empty_output><jupyter_text>Cleaning up the artifacts created in this notebook.<jupyter_code>for file in map(Path, [data_file, application]):
    file.unlink()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14356435643564355, 'fraction_numerical': 0.08316831683168317, 'mean_word_length': 5.415873015873016, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '576618', 'license': 'CC-BY-4.0', 'n_tokens_mistral': 889, 'n_tokens_neox': 787, 'n_words': 207, 'path': 'Python/SystemsProgramming/julia.ipynb', 'repo_name': 'Gjacquenot/training-material', 'size': '2020'}