Skip to content

Commit

Permalink
Retrieve binned measurements in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
UsualSpec committed Jul 10, 2024
1 parent ce4700d commit c9d6536
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions server/plotter/pages/dut.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]")
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c9d6536

Please sign in to comment.