Author: dmacvicar
Date: Fri Jul 13 00:13:41 2007
New Revision: 5997
URL: http://svn.opensuse.org/viewcvs/zypp?rev=5997&view=rev
Log:
Before, querying group() in a loop for 11.587 resolvables
u 20.06 s 1.54 c 0.00
After, querying group() in a loop for 11.587 resolvables
u 0.81 s 0.24 c 0.00
And tests still pass :-)
Modified:
branches/REFACTORING-10_3/libzypp/devel/devel.dmacvicar/CMakeLists.txt
branches/REFACTORING-10_3/libzypp/devel/devel.dmacvicar/CachedSource_tp.cc
branches/REFACTORING-10_3/libzypp/devel/devel.dmacvicar/RepositoryManager_tp.cc
branches/REFACTORING-10_3/libzypp/devel/devel.dmacvicar/testbed.cc
branches/REFACTORING-10_3/libzypp/zypp/cache/ResolvableQuery.cc
Modified: branches/REFACTORING-10_3/libzypp/devel/devel.dmacvicar/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp/devel/devel.dmacvicar/CMakeLists.txt?rev=5997&r1=5996&r2=5997&view=diff
==============================================================================
--- branches/REFACTORING-10_3/libzypp/devel/devel.dmacvicar/CMakeLists.txt (original)
+++ branches/REFACTORING-10_3/libzypp/devel/devel.dmacvicar/CMakeLists.txt Fri Jul 13 00:13:41 2007
@@ -3,20 +3,20 @@
ADD_EXECUTABLE(mediaaccess mediaaccess.cc)
TARGET_LINK_LIBRARIES(mediaaccess zypp )
-ADD_EXECUTABLE(scansource ScanSource.cc)
-TARGET_LINK_LIBRARIES(scansource zypp )
+#ADD_EXECUTABLE(scansource ScanSource.cc)
+#TARGET_LINK_LIBRARIES(scansource zypp )
-ADD_EXECUTABLE(susetags-downloader SUSETagsDownloader_tp.cc)
-TARGET_LINK_LIBRARIES(susetags-downloader zypp )
+#ADD_EXECUTABLE(susetags-downloader SUSETagsDownloader_tp.cc)
+#TARGET_LINK_LIBRARIES(susetags-downloader zypp )
ADD_EXECUTABLE(cachestore CacheStore_tp.cc)
TARGET_LINK_LIBRARIES(cachestore zypp )
-ADD_EXECUTABLE(testbed testbed.cc)
-TARGET_LINK_LIBRARIES(testbed zypp )
+#ADD_EXECUTABLE(testbed testbed.cc)
+#TARGET_LINK_LIBRARIES(testbed zypp )
-ADD_EXECUTABLE(yum-downloader YUMDownloader_tp.cc)
-TARGET_LINK_LIBRARIES(yum-downloader zypp )
+#ADD_EXECUTABLE(yum-downloader YUMDownloader_tp.cc)
+#TARGET_LINK_LIBRARIES(yum-downloader zypp )
# ADD_EXECUTABLE(yum-reader YUMReader_tp.cc)
# TARGET_LINK_LIBRARIES(yum-reader zypp )
Modified: branches/REFACTORING-10_3/libzypp/devel/devel.dmacvicar/CachedSource_tp.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp/devel/devel.dmacvicar/CachedSource_tp.cc?rev=5997&r1=5996&r2=5997&view=diff
==============================================================================
--- branches/REFACTORING-10_3/libzypp/devel/devel.dmacvicar/CachedSource_tp.cc (original)
+++ branches/REFACTORING-10_3/libzypp/devel/devel.dmacvicar/CachedSource_tp.cc Fri Jul 13 00:13:41 2007
@@ -10,7 +10,6 @@
#include "zypp/Product.h"
#include "zypp/detail/PackageImplIf.h"
#include "zypp/Package.h"
-#include "zypp/RepositoryFactory.h"
#include "zypp/repo/cached/RepoImpl.h"
#include "zypp/data/ResolvableData.h"
Modified: branches/REFACTORING-10_3/libzypp/devel/devel.dmacvicar/RepositoryManager_tp.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp/devel/devel.dmacvicar/RepositoryManager_tp.cc?rev=5997&r1=5996&r2=5997&view=diff
==============================================================================
--- branches/REFACTORING-10_3/libzypp/devel/devel.dmacvicar/RepositoryManager_tp.cc (original)
+++ branches/REFACTORING-10_3/libzypp/devel/devel.dmacvicar/RepositoryManager_tp.cc Fri Jul 13 00:13:41 2007
@@ -5,13 +5,13 @@
#include <fstream>
#include
+#include
#include
#include
#include "zypp/Product.h"
#include "zypp/detail/PackageImplIf.h"
#include "zypp/Package.h"
-#include "zypp/RepositoryFactory.h"
#include "zypp/RepoInfo.h"
#include "zypp/repo/cached/RepoImpl.h"
@@ -23,7 +23,7 @@
using namespace std;
using namespace zypp;
-using namespace zypp::source;
+using namespace zypp::repo;
int main(int argc, char **argv)
@@ -40,7 +40,25 @@
for ( RepoInfoList::const_iterator it = repos.begin(); it != repos.end(); ++it )
{
cout << *it << endl;
+ Repository repo = manager.createFromCache(*it);
+ z->addResolvables(repo.resolvables());
}
+
+ ResPool pool(z->pool());
+ cout << pool.size() << " resolvables" << endl;
+ debug::Measure m("group call");
+ for ( ResPool::const_iterator it = pool.begin();
+ it != pool.end();
+ ++it )
+ {
+ ResObject::constPtr res = (*it).resolvable();
+ if ( isKind<Package>(res) )
+ {
+ Package::constPtr p = asKind<Package>(res);
+ //cout << p->group() << std::endl;
+ }
+ }
+ m.elapsed();
}
catch ( const Exception &e )
{
Modified: branches/REFACTORING-10_3/libzypp/devel/devel.dmacvicar/testbed.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp/devel/devel.dmacvicar/testbed.cc?rev=5997&r1=5996&r2=5997&view=diff
==============================================================================
--- branches/REFACTORING-10_3/libzypp/devel/devel.dmacvicar/testbed.cc (original)
+++ branches/REFACTORING-10_3/libzypp/devel/devel.dmacvicar/testbed.cc Fri Jul 13 00:13:41 2007
@@ -10,7 +10,6 @@
#include "zypp/Product.h"
#include "zypp/detail/PackageImplIf.h"
#include "zypp/Package.h"
-#include "zypp/RepositoryFactory.h"
#include "zypp/repo/cached/RepoImpl.h"
#include "zypp/data/ResolvableData.h"
Modified: branches/REFACTORING-10_3/libzypp/zypp/cache/ResolvableQuery.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp/zypp/cache/ResolvableQuery.cc?rev=5997&r1=5996&r2=5997&view=diff
==============================================================================
--- branches/REFACTORING-10_3/libzypp/zypp/cache/ResolvableQuery.cc (original)
+++ branches/REFACTORING-10_3/libzypp/zypp/cache/ResolvableQuery.cc Fri Jul 13 00:13:41 2007
@@ -1,5 +1,6 @@
#include <iterator>
#include <algorithm>
+#include "zypp/base/PtrTypes.h"
#include "zypp/base/Logger.h"
#include "zypp/cache/CacheTypes.h"
#include "zypp/cache/ResolvableQuery.h"
@@ -8,20 +9,37 @@
using namespace sqlite3x;
using namespace std;
+using namespace zypp;
-namespace zypp { namespace cache {
+typedef shared_ptr sqlite3_command_ptr;
+namespace zypp { namespace cache {
struct ResolvableQuery::Impl
{
Pathname _dbdir;
string _fields;
CacheTypes _type_cache;
-
+ sqlite3_connection _con;
+ sqlite3_command_ptr _cmd_attr_str;
+ sqlite3_command_ptr _cmd_attr_tstr;
+ sqlite3_command_ptr _cmd_attr_num;
+
Impl( const Pathname &dbdir)
: _dbdir(dbdir)
- , _type_cache(dbdir)
+ , _type_cache(dbdir)
{
+ _con.open((dbdir + "zypp.db").asString().c_str());
+ _con.executenonquery("PRAGMA cache_size=8000;");
+
+ _cmd_attr_tstr.reset( new sqlite3_command( _con, "select a.text, l.name from text_attributes a,types l,types t where a.weak_resolvable_id=:rid and a.lang_id=l.id and a.attr_id=t.id and l.class=:lclass and t.class=:tclass and t.name=:tname;") );
+
+
+ _cmd_attr_str.reset( new sqlite3_command( _con, "select a.text from text_attributes a,types l,types t where a.weak_resolvable_id=:rid and a.lang_id=l.id and a.attr_id=t.id and l.class=:lclass and l.name=:lname and t.class=:tclass and t.name=:tname;"));
+
+
+ _cmd_attr_num.reset( new sqlite3_command( _con, "select a.value from numeric_attributes a,types t where a.weak_resolvable_id=:rid and a.attr_id=t.id and t.class=:tclass and t.name=:tname;"));
+
MIL << "Creating Resolvable query impl" << endl;
_fields = "id, name, version, release, epoch, arch, kind, installed_size, archive_size, install_only, build_time, install_time, repository_id";
}
@@ -85,10 +103,8 @@
const std::string &name,
const std::string &default_value )
{
- sqlite3_connection con((_dbdir + "zypp.db").asString().c_str());
-
string value;
- return queryStringAttributeTranslationInternal( con, record_id, Locale(), klass, name, default_value);
+ return queryStringAttributeTranslationInternal( _con, record_id, Locale(), klass, name, default_value);
}
@@ -98,8 +114,7 @@
const std::string &name,
const std::string &default_value )
{
- sqlite3_connection con((_dbdir + "zypp.db").asString().c_str());
- return queryStringAttributeTranslationInternal( con, record_id, locale, klass, name, default_value );
+ return queryStringAttributeTranslationInternal( _con, record_id, locale, klass, name, default_value );
}
@@ -108,8 +123,7 @@
const std::string &name,
const TranslatedText &default_value )
{
- sqlite3_connection con((_dbdir + "zypp.db").asString().c_str());
- return queryTranslatedStringAttributeInternal( con, record_id, klass, name, default_value );
+ return queryTranslatedStringAttributeInternal( _con, record_id, klass, name, default_value );
}
@@ -118,8 +132,7 @@
const std::string &name,
bool default_value )
{
- sqlite3_connection con((_dbdir + "zypp.db").asString().c_str());
- return ( queryNumericAttributeInternal( con, record_id, klass, name, default_value) > 0 );
+ return ( queryNumericAttributeInternal( _con, record_id, klass, name, default_value) > 0 );
}
int queryNumericAttribute( const data::RecordId &record_id,
@@ -127,8 +140,7 @@
const std::string &name,
int default_value )
{
- sqlite3_connection con((_dbdir + "zypp.db").asString().c_str());
- return queryNumericAttributeInternal( con, record_id, klass, name, default_value);
+ return queryNumericAttributeInternal( _con, record_id, klass, name, default_value);
}
private:
@@ -139,17 +151,16 @@
const std::string &name,
int default_value )
{
- con.executenonquery("BEGIN;");
- sqlite3_command cmd( con, "select a.value from numeric_attributes a,types t where a.weak_resolvable_id=:rid and a.attr_id=t.id and t.class=:tclass and t.name=:tname;");
-
- cmd.bind(":rid", record_id);
+ //con.executenonquery("BEGIN;");
+ _cmd_attr_num->bind(":rid", record_id);
- cmd.bind(":tclass", klass);
- cmd.bind(":tname", name);
+ _cmd_attr_num->bind(":tclass", klass);
+ _cmd_attr_num->bind(":tname", name);
- sqlite3_reader reader = cmd.executereader();
+ sqlite3_reader reader = _cmd_attr_num->executereader();
if ( reader.read() )
return reader.getint(0);
+
return default_value;
}
@@ -160,17 +171,16 @@
const TranslatedText &default_value )
{
//con.executenonquery("PRAGMA cache_size=8000;");
- con.executenonquery("BEGIN;");
- sqlite3_command cmd( con, "select a.text, l.name from text_attributes a,types l,types t where a.weak_resolvable_id=:rid and a.lang_id=l.id and a.attr_id=t.id and l.class=:lclass and t.class=:tclass and t.name=:tname;");
+ //con.executenonquery("BEGIN;");
- cmd.bind(":rid", record_id);
- cmd.bind(":lclass", "lang");
+ _cmd_attr_tstr->bind(":rid", record_id);
+ _cmd_attr_tstr->bind(":lclass", "lang");
- cmd.bind(":tclass", klass);
- cmd.bind(":tname", name);
+ _cmd_attr_tstr->bind(":tclass", klass);
+ _cmd_attr_tstr->bind(":tname", name);
TranslatedText result;
- sqlite3_reader reader = cmd.executereader();
+ sqlite3_reader reader = _cmd_attr_tstr->executereader();
int c = 0;
while(reader.read())
@@ -178,7 +188,7 @@
result.setText( reader.getstring(0), Locale( reader.getstring(1) ) );
c++;
}
-
+
if ( c>0 )
return result;
@@ -201,21 +211,18 @@
const std::string &name,
const std::string &default_value )
{
- //con.executenonquery("PRAGMA cache_size=8000;");
- con.executenonquery("BEGIN;");
- sqlite3_command cmd( con, "select a.text from text_attributes a,types l,types t where a.weak_resolvable_id=:rid and a.lang_id=l.id and a.attr_id=t.id and l.class=:lclass and l.name=:lname and t.class=:tclass and t.name=:tname;");
-
- cmd.bind(":rid", record_id);
- cmd.bind(":lclass", "lang");
+ //con.executenonquery("BEGIN;");
+ _cmd_attr_str->bind(":rid", record_id);
+ _cmd_attr_str->bind(":lclass", "lang");
if (locale == Locale() )
- cmd.bind(":lname", "none");
+ _cmd_attr_str->bind(":lname", "none");
else
- cmd.bind(":lname", locale.code());
+ _cmd_attr_str->bind(":lname", locale.code());
- cmd.bind(":tclass", klass);
- cmd.bind(":tname", name);
+ _cmd_attr_str->bind(":tclass", klass);
+ _cmd_attr_str->bind(":tname", name);
- sqlite3_reader reader = cmd.executereader();
+ sqlite3_reader reader = _cmd_attr_str->executereader();
if ( reader.read() )
return reader.getstring(0);
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org