Class QAccelPlot::Internal::HoverIndexBudget¶
ClassList > QAccelPlot > Internal > HoverIndexBudget
Decides when queried data is worth a hover index. More...
#include <HoverIndexBudget.hpp>
Public Types¶
| Type | Name |
|---|---|
| typedef std::chrono::duration< double, std::nano > | CostPerRecord Cost of indexing one record. Fractional, because a timed build rarely costs whole nanoseconds per record. |
Public Functions¶
| Type | Name |
|---|---|
| HoverIndexBudget (CostPerRecord assumedBuildCostPerRecord) Creates a budget that assumes assumedBuildCostPerRecord until a build has been timed. |
|
| void | addBuild (std::chrono::nanoseconds duration, int recordCount) Replaces the assumed build cost with that of a build of recordCount records. |
| void | addScan (std::chrono::nanoseconds duration) Adds the cost of one scan. |
| bool | buildDue (int recordCount) const Returns true once the scans have cost as much as indexing__recordCount records. |
| void | reset () Forgets the scans paid so far. Call when the index stops matching the data. |
| void | timeBuild (const int recordCount, Build && build) Runs build and records its duration as the cost of indexing__recordCount records. |
| auto | timeScan (Scan && scan) Runs scan , adds its duration, and returns its result. |
Detailed Description¶
A scan answers a query on any data at the cost of a pass over it. An index answers almost for free, but must be rebuilt after every data change. Queries therefore scan until the scans since the last data change have cost as much as a build would. That keeps the total within about twice the cheaper choice, whether the data changes every frame or never.
Public Types Documentation¶
typedef CostPerRecord¶
Cost of indexing one record. Fractional, because a timed build rarely costs whole nanoseconds per record.
using QAccelPlot::Internal::HoverIndexBudget::CostPerRecord = std::chrono::duration<double, std::nano>;
Public Functions Documentation¶
function HoverIndexBudget¶
Creates a budget that assumes assumedBuildCostPerRecord until a build has been timed.
explicit QAccelPlot::Internal::HoverIndexBudget::HoverIndexBudget (
CostPerRecord assumedBuildCostPerRecord
)
function addBuild¶
Replaces the assumed build cost with that of a build of recordCount records.
void QAccelPlot::Internal::HoverIndexBudget::addBuild (
std::chrono::nanoseconds duration,
int recordCount
)
Builds of few records are ignored: their fixed overhead would overstate the cost per record.
function addScan¶
Adds the cost of one scan.
function buildDue¶
Returns true once the scans have cost as much as indexing__recordCount records.
function reset¶
Forgets the scans paid so far. Call when the index stops matching the data.
function timeBuild¶
Runs build and records its duration as the cost of indexing__recordCount records.
template<typename Build>
inline void QAccelPlot::Internal::HoverIndexBudget::timeBuild (
const int recordCount,
Build && build
)
function timeScan¶
Runs scan , adds its duration, and returns its result.
template<typename Scan>
inline auto QAccelPlot::Internal::HoverIndexBudget::timeScan (
Scan && scan
)
The documentation for this class was generated from the following file QAccelPlot/src/QAccelPlot/series/internal/HoverIndexBudget.hpp