Just messing around, I'll save anyway. Profiled the multi to linear function being called each time in Update. And moved it to the class constructor but it actually slowed it down. Might be cache related? As it is the difference between computing the value on the fly vs. getting the stored value

master
MitchellHansen 9 years ago
parent 7f8673ce60
commit ca6fd8c563

@ -6,6 +6,9 @@ MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Conways", "Conways\Conways.vcxproj", "{9035B83C-F117-480E-9DEB-435AA0EBEA3F}"
EndProject
Global
GlobalSection(Performance) = preSolution
HasPerformanceSessions = true
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86

@ -147,12 +147,13 @@
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>Z:\Cpp_Libs\SFML-Visual_Studio2015RCx64\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>

@ -4,8 +4,8 @@
class Node {
public:
static const int x_bound = 1000;
static const int y_bound = 1000;
static const int x_bound = 300;
static const int y_bound = 300;
Node(sf::Vector2i position_);
~Node();
@ -23,5 +23,7 @@ private:
sf::Vector2i position;
int curr_state;
int next_state;
};

@ -6,8 +6,8 @@
#include <thread>
#include <stack>
const int WINDOW_X = 1000;
const int WINDOW_Y = 1000;
const int WINDOW_X = 300;
const int WINDOW_Y = 300;
float elap_time() {
static __int64 start = 0;
@ -43,7 +43,7 @@ int main() {
for (int x = 0; x < Node::x_bound; x++) {
for (int y = 0; y < Node::y_bound; y++) {
node_vec.push_back(Node(sf::Vector2i(x, y)));
if ((x % 30 == 0)) {
if ((x % 5 == 0) || (y % 8 == 0)) {
node_vec.at(node_vec.size() - 1).Revive();
}
}
@ -63,6 +63,7 @@ int main() {
texture.create(WINDOW_X, WINDOW_Y);
sf::Sprite sprite(texture);
while (window.isOpen()) {
sf::Event event;
@ -107,12 +108,14 @@ int main() {
}
else {
//pixel_array[i * 4] *= 0.999;// 49; // R?
pixel_array[i * 4 + 1] *= 0.999;//68; // G?
pixel_array[i * 4] *= 0.999;// 49; // R?
//pixel_array[i * 4 + 1] *= 0.999;//68; // G?
pixel_array[i * 4 + 2] *= 0.999;//72; // B?
pixel_array[i * 4 + 3] *= 0.999;//255; // A?
}
}
window.clear();
texture.update(pixel_array);
window.draw(sprite);

Loading…
Cancel
Save