From c9d6536778c1db197e7da0f1f1114040bd89024c Mon Sep 17 00:00:00 2001 From: UsualSpec <98665326+UsualSpec@users.noreply.github.com> Date: Wed, 10 Jul 2024 16:34:48 +0200 Subject: [PATCH] Retrieve binned measurements in parallel --- server/plotter/pages/dut.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/plotter/pages/dut.py b/server/plotter/pages/dut.py index 10f16a1..09dd414 100644 --- a/server/plotter/pages/dut.py +++ b/server/plotter/pages/dut.py @@ -290,8 +290,9 @@ def getMsmtVals(msmt_id): msmtDf = pd.read_sql_query(sql="EXECUTE getMmtPtsBinned (%(bintime)s, %(srvmsmtid)s, %(startts)s,%(startts)s, %(endts)s)", params={"bintime": binTime, "srvmsmtid": msmt_id, "startts": startDate, "endts": endDate}, con=createDb()) msmtDf["measurement_value"] = msmtDf["measurement_value"].div(1000) # convert mW to W return go.Scatter(x=msmtDf["measurement_timestamp"], y=msmtDf["measurement_value"], name="Measurement id " + str(msmt_id)) - allMsmtsForThisId = list(map(getMsmtVals, msmt_ids)) - plt.add_traces(allMsmtsForThisId) + with ThreadPoolExecutor(max_workers=3) as binExec: + allMsmtsForThisId = list(binExec.map(getMsmtVals, msmt_ids)) + plt.add_traces(allMsmtsForThisId) # Add x axis and y axis titles plt.update_layout(xaxis_title="Time", yaxis_title="Measured power [W]") @@ -383,6 +384,7 @@ def buildDailyPlot(): return dailyPlot with ThreadPoolExecutor(max_workers=3) as executor: + # Parallelize building plots to speed up tsPlotFuture = executor.submit(buildTimeseriesPlot) hourlyPlotFuture = executor.submit(buildHourlyPlot) dailyPlotFuture = executor.submit(buildDailyPlot)