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}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Conways", "Conways\Conways.vcxproj", "{9035B83C-F117-480E-9DEB-435AA0EBEA3F}"
EndProject EndProject
Global Global
GlobalSection(Performance) = preSolution
HasPerformanceSessions = true
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64 Debug|x64 = Debug|x64
Debug|x86 = Debug|x86 Debug|x86 = Debug|x86

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

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

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

Loading…
Cancel
Save