Mailinglist Archive: zypp-devel (83 mails)
| < Previous | Next > |
Re: [zypp-devel] Way how separate download and install package + performance test of boost::thread
- From: Josef Reidinger <jreidinger@xxxxxxx>
- Date: Tue, 10 Jun 2008 10:36:02 +0200
- Message-id: <484E3CF2.9030103@xxxxxxx>
Duncan Mac-Vicar Prett wrote:
I see that duncan use boost::thread and because I never use it I write little performance test for boost::thread if pthreads isn't better. And result is that it is almost same (different is statistical error).
boost threads:
user time: 4032
system time: 24
pthreads:
user time: 4076
system time: 14
source code attached.
Pepa
#include <iostream>
#include <sys/param.h>
#include <sys/times.h>
#include <sys/types.h>
#include <boost/thread/thread.hpp>
#include <pthread.h>
#define LOOP 1000
struct tms t,u;
using namespace std;
struct test{
void operator()() {
int j = 1;
for (int i = 0;i<1000000;i++)
j += i;
}
};
void* testp(void*){
test t;
t();
return NULL;
}
int main(){
cout << "boost threads: " <<endl;
times(&t);
for (int i=0;i<LOOP;i++)
{
test t;
boost::thread* threads[10];
for (int i = 0;i<10;++i){
threads[i] = new boost::thread(t);
}
for (int i = 0;i<10;++i){
threads[i]->join();
delete threads[i];
}
}
times(&u);
cout << "user time: " << u.tms_utime-t.tms_utime << endl;
cout << "system time: " << u.tms_stime-t.tms_stime << endl << endl;
cout << "pthreads:" <<endl;
times(&t);
for (int i=0;i<LOOP;i++)
{
pthread_t threads[10];
test t;
for (int i = 0;i<10;++i){
pthread_create(threads+i,NULL,testp,NULL);
}
for (int i = 0;i<10;++i){
pthread_join(threads[i],NULL);
}
}
times(&u);
cout << "user time: " << u.tms_utime-t.tms_utime << endl;
cout << "system time: " << u.tms_stime-t.tms_stime << endl;
return 0;
}
Stanislav Visnovsky wrote:
IIRC, Duncan has a half-finished patch for download in threaded way.(only internal)
Stano
http://w3.suse.de/~dmacvicar/libzypp/0001-first-attempt-to-do-paralell-downloads.patch
It does a nice crash :-)
I see that duncan use boost::thread and because I never use it I write little performance test for boost::thread if pthreads isn't better. And result is that it is almost same (different is statistical error).
boost threads:
user time: 4032
system time: 24
pthreads:
user time: 4076
system time: 14
source code attached.
Pepa
#include <iostream>
#include <sys/param.h>
#include <sys/times.h>
#include <sys/types.h>
#include <boost/thread/thread.hpp>
#include <pthread.h>
#define LOOP 1000
struct tms t,u;
using namespace std;
struct test{
void operator()() {
int j = 1;
for (int i = 0;i<1000000;i++)
j += i;
}
};
void* testp(void*){
test t;
t();
return NULL;
}
int main(){
cout << "boost threads: " <<endl;
times(&t);
for (int i=0;i<LOOP;i++)
{
test t;
boost::thread* threads[10];
for (int i = 0;i<10;++i){
threads[i] = new boost::thread(t);
}
for (int i = 0;i<10;++i){
threads[i]->join();
delete threads[i];
}
}
times(&u);
cout << "user time: " << u.tms_utime-t.tms_utime << endl;
cout << "system time: " << u.tms_stime-t.tms_stime << endl << endl;
cout << "pthreads:" <<endl;
times(&t);
for (int i=0;i<LOOP;i++)
{
pthread_t threads[10];
test t;
for (int i = 0;i<10;++i){
pthread_create(threads+i,NULL,testp,NULL);
}
for (int i = 0;i<10;++i){
pthread_join(threads[i],NULL);
}
}
times(&u);
cout << "user time: " << u.tms_utime-t.tms_utime << endl;
cout << "system time: " << u.tms_stime-t.tms_stime << endl;
return 0;
}
| < Previous | Next > |