74 lines
1.3 KiB
Python
Executable File
74 lines
1.3 KiB
Python
Executable File
#!/usr/bin/env python
|
|
|
|
from time import sleep, time
|
|
import streamlit as st
|
|
import altair as alt
|
|
import numpy as np
|
|
import pandas as pd
|
|
|
|
|
|
st.title(__file__.rsplit("/")[-1])
|
|
|
|
|
|
chart_data = pd.DataFrame(
|
|
np.random.randn(20, 3),
|
|
columns=['a', 'b', 'c'],
|
|
index=np.arange(10, 30)
|
|
)
|
|
|
|
ch1 = st.line_chart(chart_data)
|
|
|
|
c = alt.Chart(chart_data.reset_index()).mark_line().encode(
|
|
x='index',
|
|
y='a',
|
|
tooltip="a"
|
|
)
|
|
|
|
ch2 = st.altair_chart(c)
|
|
|
|
|
|
img_data = np.random.randn(2500, 2500)
|
|
img_data -= img_data.min()
|
|
img_data /= img_data.max()
|
|
|
|
img = st.image(img_data)
|
|
|
|
|
|
times = []
|
|
last_time = time()
|
|
|
|
for i in range(1000):
|
|
cd = pd.DataFrame(
|
|
np.random.randn(1, 3),
|
|
columns=['a', 'b', 'c'],
|
|
index=[chart_data.index.max()+1]
|
|
)
|
|
|
|
ch1.add_rows(cd)
|
|
|
|
chart_data = chart_data.append(cd)
|
|
chart_data = chart_data.iloc[1:]
|
|
|
|
c = alt.Chart(chart_data.reset_index()).mark_line().encode(
|
|
x='index',
|
|
y='a',
|
|
tooltip="a"
|
|
)
|
|
|
|
ch2.altair_chart(c)
|
|
|
|
img_data = np.random.randn(250, 250)
|
|
img_data -= img_data.min()
|
|
img_data /= img_data.max()
|
|
img.image(img_data)
|
|
|
|
current_time = time()
|
|
delta_t = current_time - last_time
|
|
times.append(delta_t)
|
|
last_time = current_time
|
|
print(delta_t, np.mean(times))
|
|
|
|
sleep(1)
|
|
|
|
|