Gaming ideas:\r
-------------\r
\r
-- How would some GTA-style ideas work?\r
- - Cars? Stealing? Unlawful stuff and cops? Lots of guns?\r
+- Aim for something like controlling a single dwarf in Dwarf Fortress.\r
\r
-- RPG style?\r
-\r
-- Space racer style?\r
\r
Documentation:\r
--------------\r
VoxelManipulator, which is faster)\r
\r
FIXME: The new texture stuff is slow on wine\r
- - Actually it is not too slow; updating excess amount of meshes\r
- when making footprints is too slow. It has to be fixed.\r
+ - A basic grassy ground block takes 20-40ms\r
+ - A bit more complicated block can take 270ms\r
+ - On linux, a similar one doesn't take long at all (14ms)\r
+ - Is it a bad std::string implementation of MSVC?\r
+ - Can take up to 200ms? Is it when loading textures or always?\r
+ - Updating excess amount of meshes when making footprints is too\r
+ slow. It has to be fixed.\r
-> implement Map::updateNodeMeshes()\r
+ TODO: Optimize TileSpec to only contain a reference number that\r
+ is fast to compare, which refers to a cached string\r
\r
Doing now:\r
----------\r
std::wstring text;\r
};\r
\r
-int main(int argc, char *argv[])\r
+// These are defined global so that they're not optimized too much.\r
+// Can't change them to volatile.\r
+s16 temp16;\r
+f32 tempf;\r
+v3f tempv3f1;\r
+v3f tempv3f2;\r
+std::string tempstring;\r
+std::string tempstring2;\r
+\r
+void SpeedTests()\r
{\r
- /*\r
- Low-level initialization\r
- */\r
+ {\r
+ dstream<<"The following test should take around 20ms."<<std::endl;\r
+ TimeTaker timer("Testing std::string speed");\r
+ const u32 jj = 10000;\r
+ for(u32 j=0; j<jj; j++)\r
+ {\r
+ tempstring = "";\r
+ tempstring2 = "";\r
+ const u32 ii = 10;\r
+ for(u32 i=0; i<ii; i++){\r
+ tempstring2 += "asd";\r
+ }\r
+ for(u32 i=0; i<ii+1; i++){\r
+ tempstring += "asd";\r
+ if(tempstring == tempstring2)\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ \r
+ dstream<<"All of the following tests should take around 100ms each."\r
+ <<std::endl;\r
\r
- bool disable_stderr = false;\r
-#ifdef _WIN32\r
- disable_stderr = true;\r
-#endif\r
+ {\r
+ TimeTaker timer("Testing floating-point conversion speed");\r
+ tempf = 0.001;\r
+ for(u32 i=0; i<4000000; i++){\r
+ temp16 += tempf;\r
+ tempf += 0.001;\r
+ }\r
+ }\r
+ \r
+ {\r
+ TimeTaker timer("Testing floating-point vector speed");\r
\r
- // Initialize debug streams\r
- debugstreams_init(disable_stderr, DEBUGFILE);\r
- // Initialize debug stacks\r
- debug_stacks_init();\r
+ tempv3f1 = v3f(1,2,3);\r
+ tempv3f2 = v3f(4,5,6);\r
+ for(u32 i=0; i<10000000; i++){\r
+ tempf += tempv3f1.dotProduct(tempv3f2);\r
+ tempv3f2 += v3f(7,8,9);\r
+ }\r
+ }\r
\r
- DSTACK(__FUNCTION_NAME);\r
+ {\r
+ TimeTaker timer("Testing core::map speed");\r
+ \r
+ core::map<v2s16, f32> map1;\r
+ tempf = -324;\r
+ const s16 ii=300;\r
+ for(s16 y=0; y<ii; y++){\r
+ for(s16 x=0; x<ii; x++){\r
+ map1.insert(v2s16(x,y), tempf);\r
+ tempf += 1;\r
+ }\r
+ }\r
+ for(s16 y=ii-1; y>=0; y--){\r
+ for(s16 x=0; x<ii; x++){\r
+ tempf = map1[v2s16(x,y)];\r
+ }\r
+ }\r
+ }\r
\r
- porting::initializePaths();\r
- // Create user data directory\r
- fs::CreateDir(porting::path_userdata);\r
- \r
- // C-style stuff initialization\r
- initializeMaterialProperties();\r
- init_mapnode();\r
+ {\r
+ dstream<<"Around 5000/ms should do well here."<<std::endl;\r
+ TimeTaker timer("Testing mutex speed");\r
+ \r
+ JMutex m;\r
+ m.Init();\r
+ u32 n = 0;\r
+ u32 i = 0;\r
+ do{\r
+ n += 10000;\r
+ for(; i<n; i++){\r
+ m.Lock();\r
+ m.Unlock();\r
+ }\r
+ }\r
+ // Do at least 10ms\r
+ while(timer.getTime() < 10);\r
\r
- // Debug handler\r
- BEGIN_DEBUG_EXCEPTION_HANDLER\r
+ u32 dtime = timer.stop();\r
+ u32 per_ms = n / dtime;\r
+ std::cout<<"Done. "<<dtime<<"ms, "\r
+ <<per_ms<<"/ms"<<std::endl;\r
+ }\r
+}\r
\r
- // Print startup message\r
- dstream<<DTIME<<"minetest-c55"\r
- " with SER_FMT_VER_HIGHEST="<<(int)SER_FMT_VER_HIGHEST\r
- <<", "<<BUILD_INFO\r
- <<std::endl;\r
- \r
+int main(int argc, char *argv[])\r
+{\r
/*\r
Parse command line\r
*/\r
allowed_options.insert("disable-unittests", ValueSpec(VALUETYPE_FLAG));\r
allowed_options.insert("enable-unittests", ValueSpec(VALUETYPE_FLAG));\r
allowed_options.insert("map-dir", ValueSpec(VALUETYPE_STRING));\r
+#ifdef _WIN32\r
+ allowed_options.insert("dstream-on-stderr", ValueSpec(VALUETYPE_FLAG));\r
+#endif\r
+ allowed_options.insert("speedtests", ValueSpec(VALUETYPE_FLAG));\r
\r
Settings cmd_args;\r
\r
\r
return cmd_args.getFlag("help") ? 0 : 1;\r
}\r
+ \r
+ /*\r
+ Low-level initialization\r
+ */\r
+\r
+ bool disable_stderr = false;\r
+#ifdef _WIN32\r
+ if(cmd_args.getFlag("dstream-on-stderr") == false)\r
+ disable_stderr = true;\r
+#endif\r
\r
+ // Initialize debug streams\r
+ debugstreams_init(disable_stderr, DEBUGFILE);\r
+ // Initialize debug stacks\r
+ debug_stacks_init();\r
\r
+ DSTACK(__FUNCTION_NAME);\r
+\r
+ porting::initializePaths();\r
+ // Create user data directory\r
+ fs::CreateDir(porting::path_userdata);\r
+ \r
+ // C-style stuff initialization\r
+ initializeMaterialProperties();\r
+ init_mapnode();\r
+\r
+ // Debug handler\r
+ BEGIN_DEBUG_EXCEPTION_HANDLER\r
+\r
+ // Print startup message\r
+ dstream<<DTIME<<"minetest-c55"\r
+ " with SER_FMT_VER_HIGHEST="<<(int)SER_FMT_VER_HIGHEST\r
+ <<", "<<BUILD_INFO\r
+ <<std::endl;\r
+ \r
/*\r
Basic initialization\r
*/\r
g_device = device;\r
g_irrlicht = new IrrlichtWrapper(device);\r
\r
- //g_device = device;\r
+ /*\r
+ Speed tests (done after irrlicht is loaded to get timer)\r
+ */\r
+ if(cmd_args.getFlag("speedtests"))\r
+ {\r
+ dstream<<"Running speed tests"<<std::endl;\r
+ SpeedTests();\r
+ return 0;\r
+ }\r
\r
device->setResizable(true);\r
\r