Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,7 @@ import pandas as pd
|
|
| 4 |
import duckdb
|
| 5 |
import gradio as gr
|
| 6 |
import matplotlib.pyplot as plt
|
|
|
|
| 7 |
import io
|
| 8 |
|
| 9 |
duckdb_con = duckdb.connect(database=":memory:")
|
|
@@ -150,7 +151,7 @@ def run_benchmark(operation, df, repeats):
|
|
| 150 |
|
| 151 |
|
| 152 |
# ----------------------------------------------------------
|
| 153 |
-
# Chart generator (
|
| 154 |
# ----------------------------------------------------------
|
| 155 |
|
| 156 |
def generate_chart(result):
|
|
@@ -167,11 +168,13 @@ def generate_chart(result):
|
|
| 167 |
plt.tight_layout()
|
| 168 |
plt.savefig(buf, format="png")
|
| 169 |
buf.seek(0)
|
| 170 |
-
|
|
|
|
|
|
|
| 171 |
|
| 172 |
|
| 173 |
# ----------------------------------------------------------
|
| 174 |
-
# Formatting
|
| 175 |
# ----------------------------------------------------------
|
| 176 |
|
| 177 |
def format_result(result):
|
|
@@ -209,7 +212,7 @@ theme = gr.themes.Soft(primary_hue="indigo", neutral_hue="slate")
|
|
| 209 |
|
| 210 |
with gr.Blocks(title="DuckDB vs Pandas Benchmark", theme=theme) as demo:
|
| 211 |
|
| 212 |
-
gr.Markdown("# 🐼 vs 🦆 DuckDB vs Pandas Performance Playground")
|
| 213 |
|
| 214 |
with gr.Tabs():
|
| 215 |
|
|
|
|
| 4 |
import duckdb
|
| 5 |
import gradio as gr
|
| 6 |
import matplotlib.pyplot as plt
|
| 7 |
+
from PIL import Image
|
| 8 |
import io
|
| 9 |
|
| 10 |
duckdb_con = duckdb.connect(database=":memory:")
|
|
|
|
| 151 |
|
| 152 |
|
| 153 |
# ----------------------------------------------------------
|
| 154 |
+
# Chart generator (PIL Image) — FIXED
|
| 155 |
# ----------------------------------------------------------
|
| 156 |
|
| 157 |
def generate_chart(result):
|
|
|
|
| 168 |
plt.tight_layout()
|
| 169 |
plt.savefig(buf, format="png")
|
| 170 |
buf.seek(0)
|
| 171 |
+
plt.close(fig)
|
| 172 |
+
|
| 173 |
+
return Image.open(buf)
|
| 174 |
|
| 175 |
|
| 176 |
# ----------------------------------------------------------
|
| 177 |
+
# Markdown Formatting
|
| 178 |
# ----------------------------------------------------------
|
| 179 |
|
| 180 |
def format_result(result):
|
|
|
|
| 212 |
|
| 213 |
with gr.Blocks(title="DuckDB vs Pandas Benchmark", theme=theme) as demo:
|
| 214 |
|
| 215 |
+
gr.Markdown("# 🐼 vs 🦆 DuckDB vs Pandas — Performance Playground")
|
| 216 |
|
| 217 |
with gr.Tabs():
|
| 218 |
|