diff --git a/README.md b/README.md index bd7175c..9d119de 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ export OS=linux Finally run this cargo nextest test command to get the benchmarks: ```bash -source .env/bin/activate; cargo nextest run benchmarking_tests::tests::run_benchmarks_ --test-threads 1 +source .env/bin/activate; cargo nextest run benchmarking_tests::tests::run_benchmarks_ --no-capture ``` The data will stored in a `benchmarks.json` file in the root directory. diff --git a/notebooks/random_forests/ezkl.ipynb b/notebooks/random_forests/ezkl.ipynb index 2f735b4..b51cd34 100644 --- a/notebooks/random_forests/ezkl.ipynb +++ b/notebooks/random_forests/ezkl.ipynb @@ -269,81 +269,6 @@ "assert os.path.isfile(settings_path)" ] }, - { - "cell_type": "code", - "execution_count": null, - "id": "47d01286", - "metadata": {}, - "outputs": [], - "source": [ - "import os\n", - "import json\n", - "import time\n", - "import subprocess\n", - "\n", - "def get_memory_usage(pid):\n", - " \"\"\"Function to get memory usage of process by PID.\"\"\"\n", - " try:\n", - " # Execute Bash command to get memory usage\n", - " process = subprocess.Popen(['ps', '-o', 'rss=', '-p', str(pid)],\n", - " stdout=subprocess.PIPE,\n", - " stderr=subprocess.PIPE)\n", - " stdout, stderr = process.communicate()\n", - " # Convert output to int and return\n", - " return int(stdout)\n", - " except Exception as e:\n", - " print(f\"Error getting memory usage: {e}\")\n", - " return 0\n", - "\n", - "proof_path = os.path.join('test.pf')\n", - "# log time and memory it takes to generate proof\n", - "start = time.time()\n", - "pid = os.getpid()\n", - "initial_memory = get_memory_usage(pid)\n", - "\n", - "res = ezkl.prove(\n", - " witness_path,\n", - " compiled_model_path,\n", - " pk_path,\n", - " proof_path,\n", - " \"single\",\n", - ")\n", - "\n", - "final_memory = get_memory_usage(pid)\n", - "end = time.time()\n", - "proving_time = end - start\n", - "memory_used = final_memory - initial_memory\n", - "\n", - "print(\"PROOF GENERATION TIME: \", proving_time)\n", - "print(\"MEMORY USAGE: \", memory_used, \"KB\")\n", - "\n", - "# define the path that stores the benchmarking results\n", - "benchmark_path = os.path.join('../../benchmarks.json')\n", - "\n", - "# assume benchmark file has already been created (run `bash benchmark_file.sh` to create it)\n", - "with open(benchmark_path, 'r') as f:\n", - " benchmark = json.load(f)\n", - "\n", - "proving_time =str(proving_time) + \"s\"\n", - "\n", - "memory_used = str(memory_used) + \"kb\"\n", - "\n", - "# Update the proving time in the loaded benchmark\n", - "benchmark['random_forests']['ezkl']['provingTime'].append(proving_time)\n", - "\n", - "# Update the memory usage in the loaded benchmark\n", - "benchmark['random_forests']['ezkl']['memoryUsage'].append(memory_used)\n", - "\n", - "\n", - "# Write the updated benchmark back to the file\n", - "with open(benchmark_path, 'w') as f:\n", - " json.dump(benchmark, f, indent=4)\n", - "\n", - "\n", - "print(res['instances'])\n", - "assert os.path.isfile(proof_path)" - ] - }, { "cell_type": "code", "execution_count": null,