Skip to content

Commit 4c0276c

Browse files
committed
*** benchmarks
1 parent 66a4b86 commit 4c0276c

File tree

8 files changed

+144
-5
lines changed

8 files changed

+144
-5
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ set(SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/source")
77
set(LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libraries")
88
set(SOURCES libraries/stb_image.h source/io.h source/messages.h source/ogl/PointModel.cpp source/ogl/PointModel.h source/ogl/ProgramShader.cpp
99
source/ogl/ProgramShader.h source/ogl/Shader.cpp source/ogl/Shader.h source/ogl/Plane.cpp source/ogl/Plane.h source/ogl/Texture.h source/ogl/Texture.cpp
10-
source/main.cpp source/ogl/FontRenderer.h source/ogl/FontRenderer.cpp source/wmgr/LayoutManager.cpp source/wmgr/LayoutManager.h source/wmgr/wsize.cpp source/wmgr/wsize.h source/wmgr/LayoutConstraint.cpp source/wmgr/LayoutConstraint.h source/ogl/ShaderLoader.cpp source/ogl/ShaderLoader.h source/dataflow/Context.cpp source/dataflow/Context.h source/dataflow/ContextPath.cpp source/dataflow/ContextPath.h source/dataflow/Endpoint.cpp source/dataflow/Endpoint.h source/ogl/UniformType.cpp source/ogl/UniformType.h source/dataflow/ComputeNode.cpp source/dataflow/ComputeNode.h source/nodeprims/Layouts.cpp source/nodeprims/Layouts.h source/nodeprims/Math.cpp source/nodeprims/Math.h source/nodeprims/macro_shenanigans.h source/utils/Randoms.cpp source/utils/Randoms.h source/nodeprims/Shaders.cpp source/nodeprims/Shaders.h source/testbench.cpp source/testbench.h source/utils/BitSet.cpp source/utils/BitSet.h source/utils/BitMap2D.h source/nodeprims/Rendering.cpp source/nodeprims/Rendering.h source/utils/std_colors.h)
10+
source/main.cpp source/ogl/FontRenderer.h source/ogl/FontRenderer.cpp source/wmgr/LayoutManager.cpp source/wmgr/LayoutManager.h source/wmgr/wsize.cpp source/wmgr/wsize.h source/wmgr/LayoutConstraint.cpp source/wmgr/LayoutConstraint.h source/ogl/ShaderLoader.cpp source/ogl/ShaderLoader.h source/dataflow/Context.cpp source/dataflow/Context.h source/dataflow/ContextPath.cpp source/dataflow/ContextPath.h source/dataflow/Endpoint.cpp source/dataflow/Endpoint.h source/ogl/UniformType.cpp source/ogl/UniformType.h source/dataflow/ComputeNode.cpp source/dataflow/ComputeNode.h source/nodeprims/Layouts.cpp source/nodeprims/Layouts.h source/nodeprims/Math.cpp source/nodeprims/Math.h source/nodeprims/macro_shenanigans.h source/utils/Randoms.cpp source/utils/Randoms.h source/nodeprims/Shaders.cpp source/nodeprims/Shaders.h source/testbench.cpp source/testbench.h source/utils/BitSet.cpp source/utils/BitSet.h source/utils/BitMap2D.h source/nodeprims/Rendering.cpp source/nodeprims/Rendering.h source/utils/std_colors.h source/Foo.cpp source/Foo.h source/Bar.cpp source/Bar.h)
1111

1212
# Executable definition and properties
1313
set(CMAKE_CXX_STANDARD 17)

shaders/ui/button.frag

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ void main() {
6969
tu = df_circle(cscale(uv, 1 + border_size));
7070
}*/
7171

72-
vec2 sq_size = vec2(0.475, 0.10) * uv_norm;
72+
vec2 sq_size = vec2(0.4, 0.4) * uv_norm;
7373
float sq_dist = df_square(nuv-uv_norm*0.5, sq_size);
7474
float circ_dist = df_circle(nuv-0.5 - vec2(value * sq_size.x*2.0 - 0.2, 0.0), 0.0);
7575

7676

77-
final_color = fblend(final_color, color, inside(0.1, g_bw, g_tr, sq_dist));
77+
final_color = fblend(final_color, color, inside(0.2, g_bw, g_tr, sq_dist));
7878

7979
out_color = final_color;
8080

source/Bar.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//
2+
// Created by david on 10/02/2020.
3+
//
4+
5+
#include "Bar.h"

source/Bar.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// Created by david on 10/02/2020.
3+
//
4+
5+
#ifndef GRAPHKAT_BAR_H
6+
#define GRAPHKAT_BAR_H
7+
8+
9+
class Bar {
10+
public:
11+
int c;
12+
};
13+
14+
15+
#endif //GRAPHKAT_BAR_H

source/Foo.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//
2+
// Created by david on 10/02/2020.
3+
//
4+
5+
#include "Foo.h"
6+
7+
Foo::Foo(Bar &bar) : bar(bar) {
8+
}

source/Foo.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// Created by david on 10/02/2020.
3+
//
4+
5+
#ifndef GRAPHKAT_FOO_H
6+
#define GRAPHKAT_FOO_H
7+
8+
9+
#include "Bar.h"
10+
11+
class Foo {
12+
public:
13+
Bar &bar;
14+
15+
Foo(Bar &bar);
16+
17+
};
18+
19+
20+
#endif //GRAPHKAT_FOO_H

source/main.cpp

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#include <boost/variant.hpp>
3333
#include <testbench.h>
3434
#include <utils/BitMap2D.h>
35+
#include <Foo.h>
36+
#include <Bar.h>
3537

3638
using namespace std;
3739
using namespace glm;
@@ -301,7 +303,7 @@ Context *buildScene() {
301303
Context *p3 = createSlider(vec2(0, 0.4), vec2(1, 0.2), 0.1f);
302304
Context *p4 = createSlider(vec2(0, 0.6), vec2(1, 0.2), 0.1f);
303305
Context *p5 = createSlider(vec2(0, 0.8), vec2(1, 0.2), 0.1f);
304-
Context *p6 = createButton(vec2(0.3, 0.1), vec2(0.1, 0.2), 0.1f);
306+
Context *p6 = createButton(vec2(0.3, 0.1), vec2(0.1, 0.05), 0.1f);
305307

306308
ECV(p1, color, vec3(0.3, 0.8, 1.0));
307309
ECV(p2, color, vec3(0.3, 0.8, 1.0));
@@ -344,7 +346,93 @@ Context *buildScene() {
344346
return scene_ctx;
345347
}
346348

349+
void indirect_tb() {
350+
vector<int> original;
351+
vector<int> first;
352+
vector<int> second;
353+
vector<int> third;
354+
355+
int N = 1000000;
356+
357+
for (int i = 0; i < N; i++) {
358+
original.push_back(i);
359+
first.push_back(original[i]);
360+
second.push_back(first[i]);
361+
third.push_back(second[i]);
362+
}
363+
364+
365+
int total = 0;
366+
auto t0 = std::chrono::high_resolution_clock::now();
367+
368+
for (int i = 0; i < N; i++) {
369+
total += original[first[second[third[i]]]];
370+
371+
}
372+
373+
auto t1 = std::chrono::high_resolution_clock::now();
374+
375+
cout << "Avg time:"
376+
<< static_cast<int>(std::chrono::duration_cast<std::chrono::microseconds>(t1 - t0).count()) / 1000
377+
<< ", ans: " << total << "\n";
378+
379+
total = 0;
380+
t0 = std::chrono::high_resolution_clock::now();
381+
382+
for (int i = 0; i < N; i++) {
383+
total += original[first[i]];
384+
}
385+
386+
t1 = std::chrono::high_resolution_clock::now();
387+
388+
cout << "Avg time:"
389+
<< static_cast<int>(std::chrono::duration_cast<std::chrono::microseconds>(t1 - t0).count()) / 1000
390+
<< ", ans: " << total << "\n";
391+
392+
total = 0;
393+
t0 = std::chrono::high_resolution_clock::now();
394+
395+
for (int i = 0; i < N; i++) {
396+
total += original[first[second[i]]];
397+
}
398+
399+
t1 = std::chrono::high_resolution_clock::now();
400+
401+
cout << "Avg time:"
402+
<< static_cast<int>(std::chrono::duration_cast<std::chrono::microseconds>(t1 - t0).count()) / 1000
403+
<< ", ans: " << total << "\n";
404+
405+
total = 0;
406+
t0 = std::chrono::high_resolution_clock::now();
407+
408+
for (int i = 0; i < N; i++) {
409+
total += original[i];
410+
}
411+
412+
t1 = std::chrono::high_resolution_clock::now();
413+
414+
cout << "Avg time:"
415+
<< static_cast<int>(std::chrono::duration_cast<std::chrono::microseconds>(t1 - t0).count()) / 1000
416+
<< ", ans: " << total << "\n";
417+
418+
fatal_error();
419+
}
420+
347421
int main(int argc, char *argv[]) {
422+
423+
Bar b;
424+
b.c = 100;
425+
Foo f = Foo(b);
426+
b.c = 200;
427+
cout << f.bar.c;
428+
fatal_error();
429+
430+
std::string_view names[] = {"ana", "are", "mere", "djkfhksjfdfnrekfnkerjnferbhvbivnvnrjnjkdnkfjvndkjg"};
431+
432+
cout << sizeof(names) << "/" << sizeof(std::string_view) << "\n";
433+
for (int i = 0; i < sizeof(names) / sizeof(std::string_view); i++)
434+
cout << names[i] << "\n";
435+
348436
auto in_ctx = new Context();
349437
auto out_ctx = new Context();
350438

source/ogl/Plane.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ class Plane {
3333

3434
static void RenderPlane(Context *in_ctx, Context *out_ctx);
3535

36-
36+
constexpr static const std::string_view _endpoint_rmap[] = {"origin", "size", "z", "plane"};
37+
enum Endpoints {
38+
origin, size, z, plane, _end
39+
};
3740
private:
3841

3942
void init(bool invertY = false);

0 commit comments

Comments
 (0)