Adjusting the regulators and moving task to use chrono nad interesting tests

This commit is contained in:
Sam Gateau 2018-04-23 00:07:00 -07:00
parent 99a0e42b5d
commit 97934fe563
6 changed files with 60 additions and 31 deletions

View file

@ -17,10 +17,12 @@
#pragma optimize( "[optimization-list]", off )
ControlViews::ControlViews() {
regionBackFronts[0] = glm::vec2(2.0f, 10.0f);
regionBackFronts[1] = glm::vec2(5.0f, 30.0f);
regionBackFronts[2] = glm::vec2(10.0f, 100.0f);
regionBackFronts[0] = glm::vec2(1.0f, 3.0f);
regionBackFronts[1] = glm::vec2(2.0f, 10.0f);
regionBackFronts[2] = glm::vec2(4.0f, 20.0f);
regionRegulators[0] = Regulator(std::chrono::milliseconds(2), regionBackFronts[0], 5.0f * regionBackFronts[0], glm::vec2(0.3f, 0.2f), 0.5f * glm::vec2(0.3f, 0.2f));
regionRegulators[1] = Regulator(std::chrono::milliseconds(2), regionBackFronts[1], 5.0f * regionBackFronts[1], glm::vec2(0.3f, 0.2f), 0.5f * glm::vec2(0.3f, 0.2f));
regionRegulators[2] = Regulator(std::chrono::milliseconds(2), regionBackFronts[2], 5.0f * regionBackFronts[2], glm::vec2(0.3f, 0.2f), 0.5f * glm::vec2(0.3f, 0.2f));
}
void ControlViews::configure(const Config& config) {
@ -62,6 +64,7 @@ void ControlViews::regulateViews(workload::Views& outViews, const workload::Timi
}
auto loopDuration = std::chrono::nanoseconds{ std::chrono::milliseconds(16) };
regionBackFronts[workload::Region::R1] = regionRegulators[workload::Region::R1].run(loopDuration, timings[0], regionBackFronts[workload::Region::R1]);
regionBackFronts[workload::Region::R2] = regionRegulators[workload::Region::R2].run(loopDuration, timings[0], regionBackFronts[workload::Region::R2]);
regionBackFronts[workload::Region::R3] = regionRegulators[workload::Region::R3].run(loopDuration, timings[1], regionBackFronts[workload::Region::R3]);

View file

@ -71,6 +71,8 @@ struct Regulator {
Regulator() {}
Regulator(const Timing_ns& budget_ns, const glm::vec2& minRange, const glm::vec2& maxRange, const glm::vec2& speedDown, const glm::vec2& speedUp) :
_budget(budget_ns), _minRange(minRange), _maxRange(maxRange), _speedDown(speedDown), _speedUp(speedUp) {}
glm::vec2 run(const Timing_ns& regulationDuration, const Timing_ns& measured, const glm::vec2& current);
};

View file

@ -149,7 +149,7 @@ class DebugSubsurfaceScatteringConfig : public render::Job::Config {
Q_PROPERTY(bool showCursorPixel MEMBER showCursorPixel NOTIFY dirty)
Q_PROPERTY(glm::vec2 debugCursorTexcoord MEMBER debugCursorTexcoord NOTIFY dirty)
public:
DebugSubsurfaceScatteringConfig() : render::Job::Config(true) {}
DebugSubsurfaceScatteringConfig() : render::Job::Config(false) {}
bool showProfile{ false };
bool showLUT{ false };

View file

@ -12,6 +12,8 @@
#ifndef hifi_task_Config_h
#define hifi_task_Config_h
#include <chrono>
#include <QtCore/qobject.h>
#include <QtCore/qjsondocument.h>
#include <QtCore/qjsonobject.h>
@ -112,7 +114,7 @@ public:
// Running Time measurement
// The new stats signal is emitted once per run time of a job when stats (cpu runtime) are updated
void setCPURunTime(double mstime) { _msCPURunTime = mstime; emit newStats(); }
void setCPURunTime(const std::chrono::nanoseconds& runtime) { _msCPURunTime = runtime.count() / 1000000.0; emit newStats(); }
double getCPURunTime() const { return _msCPURunTime; }
Q_INVOKABLE virtual bool isTask() const { return false; }

View file

@ -84,7 +84,7 @@ public:
virtual QConfigPointer& getConfiguration() { return _config; }
virtual void applyConfiguration() = 0;
void setCPURunTime(double mstime) { std::static_pointer_cast<Config>(_config)->setCPURunTime(mstime); }
void setCPURunTime(const std::chrono::nanoseconds& runtime) { std::static_pointer_cast<Config>(_config)->setCPURunTime(runtime); }
QConfigPointer _config;
protected:
@ -208,11 +208,12 @@ public:
PerformanceTimer perfTimer(getName().c_str());
// NOTE: rather than use the PROFILE_RANGE macro, we create a Duration manually
Duration profileRange(jobContext->profileCategory, ("run::" + getName()).c_str());
auto start = usecTimestampNow();
auto startTime = std::chrono::high_resolution_clock::now();
_concept->run(jobContext);
_concept->setCPURunTime((double)(usecTimestampNow() - start) / 1000.0);
_concept->setCPURunTime((std::chrono::high_resolution_clock::now() - startTime));
}
protected:

View file

@ -3,7 +3,7 @@
var GRID_WORLD_SIZE = 100.0;
var GRID_WORLD_MARGIN = 5.0;
var GRID_WORLD_RESOLUTION = 30.0;
var GRID_WORLD_DROP_HEIGHT = 5.0;
var GRID_WORLD_DROP_HEIGHT = 4.0;
var GRID_SIZE = GRID_WORLD_RESOLUTION;
var GRID_HALFSIZE = GRID_SIZE *0.5;
@ -34,6 +34,7 @@
}
var OBJECT_DIM = { x: 0.5, y: 0.5, z: 0.5};
var CONE_DIM = { x: 0.3104, y: 0.3336, z: 0.3104};
var OBJECT_SPIN = { x: 0.5, y: 0.5, z: 0.5};
var shapeTypes = [
@ -53,29 +54,49 @@ function getTileColor(a, b, c) {
}
function addObject(a, b, c, lifetime) {
var center = getStagePosOriAt(a, b, c).pos;
var center = getStagePosOriAt(a, b, c).pos;
var offset = (Math.abs(a) + (Math.abs(b) % 2)) % 2;
var makePrim = (offset > 0 ? true : false) ;
if (makePrim) {
return (Entities.addEntity({
type: "Shape",
shape: "Sphere",
name: "object-" + a + b + c,
color: getTileColor(a, b, c),
position: center,
rotation: stageOrientation,
dimensions: OBJECT_DIM,
lifetime: (lifetime === undefined) ? DEFAULT_LIFETIME : lifetime,
shapeType:shapeTypes[2],
dynamic: true,
gravity:{"x":0,"y":-9.8,"z":0},
velocity:{"x":0,"y":0.02,"z":0},
angularVelocity:OBJECT_SPIN,
restitution:0.70,
friction:0.01,
damping:0.001,
return (Entities.addEntity({
type: "Shape",
shape: "Sphere",
name: "Backdrop",
color: getTileColor(a, b, c),
position: center,
rotation: stageOrientation,
dimensions: OBJECT_DIM,
lifetime: (lifetime === undefined) ? DEFAULT_LIFETIME : lifetime,
shapeType:shapeTypes[2],
dynamic: true,
gravity:{"x":0,"y":-9.8,"z":0},
velocity:{"x":0,"y":0.02,"z":0},
angularVelocity:OBJECT_SPIN,
restitution:0.70,
friction:0.01,
damping:0.001,
}));
} else {
return (Entities.addEntity({
type: "Model",
name: "object-" + a + b + c,
position: center,
rotation: stageOrientation,
dimensions: OBJECT_DIM,
lifetime: (lifetime === undefined) ? DEFAULT_LIFETIME : lifetime,
modelURL: "https://hifi-content.s3.amazonaws.com/jimi/props/cones/trafficCone.fbx",
shapeType:shapeTypes[4],
dynamic: true,
gravity:{"x":0,"y":-9.8,"z":0},
velocity:{"x":0,"y":0.02,"z":0},
angularVelocity:OBJECT_SPIN,
restitution:0.70,
friction:0.01,
damping:0.01,
}));
}));
}
}
function addObjectGrid(backdrop, lifetime) {