Author: suokko
Date: Mon Sep 1 01:25:46 2008
New Revision: 29151
URL: http://svn.gna.org/viewcvs/wesnoth?rev=29151&view=rev
Log:
* Added performance test for config_cache
* added some comments to config_cache
Modified:
trunk/src/config_cache.hpp
trunk/src/game_config.cpp
trunk/src/tests/test_config_cache.cpp
Modified: trunk/src/config_cache.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/config_cache.hpp?rev=29151&r1=29150&r2=29151&view=diff
==============================================================================
--- trunk/src/config_cache.hpp (original)
+++ trunk/src/config_cache.hpp Mon Sep 1 01:25:46 2008
@@ -11,6 +11,11 @@
See the COPYING file for more details.
*/
+
+/**
+ * this file implements game config caching
+ * to speed up startup
+ ***/
#ifndef CONFIG_CACHE_HPP_INCLUDED
#define CONFIG_CACHE_HPP_INCLUDED
@@ -40,6 +45,7 @@
std::string path_;
public:
/**
+ * adds normal preproc define
* @params name of preproc define to add
* @aprams true if we should add this
**/
@@ -48,12 +54,19 @@
if (add_)
T::instance().add_define(name_);
}
+
+ /**
+ * adds path specific preproc define
+ **/
scoped_preproc_define_internal(const
std::string& path, const std::string& name, bool add = true) : name_(name),
add_(add), path_(path)
{
if (add_)
T::instance().add_path_define(path_, name_);
}
+ /**
+ * This removes preproc define from cacher
+ **/
~scoped_preproc_define_internal()
{
if(add_)
@@ -72,11 +85,13 @@
typedef boost::shared_ptr<scoped_preproc_define>
scoped_preproc_define_ptr;
typedef std::list<scoped_preproc_define_ptr> scoped_preproc_define_list;
/**
- * Singleton object to manage game configs
- * and cache reading.
+ * Singleton class to manage game config file caching.
+ * It uses paths to config files as key to find correct cache
* @TODO: Make smarter filetree checksum caching so only required parts
* of tree are checked at startup. Trees are overlapping
so have
* to split trees to subtrees to only do check once per
file.
+ * @TODO: Make cache system easily allow validation of in memory cache
objects
+ * using hash checksum of preproc_map.
**/
class config_cache : private boost::noncopyable {
public:
@@ -173,13 +188,19 @@
struct add_define_from_file;
class fake_transaction;
/**
- * Used to share macros between load operations
- * It uses empty map if no transaction is started
+ * Used to share macros between cache objects
+ * You have to create transaction object to load all
+ * macros to memory and share them subsequent cache loads.
+ * If transaction is locked all stored macros are still
+ * available but new macros aren't added.
**/
class config_cache_transaction : private boost::noncopyable {
public:
config_cache_transaction();
~config_cache_transaction();
+ /**
+ * Lock the transaction so no more macros are added
+ **/
void lock();
enum state { FREE,
@@ -190,10 +211,11 @@
typedef std::vector<std::string> filenames;
/**
- * Used to let std::for_each insert defines from another
+ * Used to let std::for_each insert new defines to active_map
* map to active
**/
void insert_to_active(const preproc_map::value_type& def);
+
private:
static state state_;
static config_cache_transaction* active_;
Modified: trunk/src/game_config.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_config.cpp?rev=29151&r1=29150&r2=29151&view=diff
==============================================================================
--- trunk/src/game_config.cpp (original)
+++ trunk/src/game_config.cpp Mon Sep 1 01:25:46 2008
@@ -55,7 +55,7 @@
bool use_dummylocales = false;
- int cache_compression_level = 5;
+ int cache_compression_level = 6;
std::string game_icon = "wesnoth-icon.png", game_title, game_logo,
title_music, lobby_music;
int title_logo_x = 0, title_logo_y = 0, title_buttons_x = 0,
title_buttons_y = 0, title_buttons_padding = 0,
Modified: trunk/src/tests/test_config_cache.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/tests/test_config_cache.cpp?rev=29151&r1=29150&r2=29151&view=diff
==============================================================================
--- trunk/src/tests/test_config_cache.cpp (original)
+++ trunk/src/tests/test_config_cache.cpp Mon Sep 1 01:25:46 2008
@@ -285,6 +285,22 @@
cache.set_force_not_valid_cache(false);
}
+#if 0
+// for profiling cache speed
+BOOST_AUTO_TEST_CASE( test_performance )
+{
+ test_scoped_define mp("MULTIPLAYER");
+ config cfg_ref;
+ cache.set_force_not_valid_cache(true);
+ cache.get_config("data/", cfg_ref);
+ cache.set_force_not_valid_cache(false);
+ for (int i=0; i < 3; ++i)
+ {
+ cache.get_config("data/");
+ }
+}
+#endif
+
/* vim: set ts=4 sw=4: */
BOOST_AUTO_TEST_SUITE_END()
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits