wget -m -k -K -E -l 2 http://www.daum.net
This SQL version is for SQLite, so if u want to apply to MySQL or other DBMS,
you can change 'strftime('%s','now') - 7 * 86400' to use your DBMS's date function.
mix1009님의 글을 보고 '7일간 활동한 작업을 개발자별로 확인하기' 트랙 리포트를 만들어보았습니다.
이 버전은 SQLite를 위한 것이므로 다른 DBMS를 쓸 경우 아래 녹색 부분을 해당 DBMS date function에 맞도록 수정해서 쓰시면 됩니다. SQL 성능은 좀...^^
select
p.value AS __color__,
owner AS __group__,
id AS ticket,
(CASE status WHEN 'assigned' THEN owner||' *' ELSE owner END) AS owner,
summary,
component,
priority,
t.type AS type,
status,
time AS _created,
changetime AS modified,
description AS _description,
reporter AS _reporterfrom (
SELECT *
FROM ticket
where changetime > strftime('%s','now') - 7 * 86400
order by changetime desc) t, enum p
where p.name = t.priority AND p.type = 'priority'
order by owner, changetime desc
p.s. Trac's default index schema doesn't gurantee good performance of this script. If u have performance problem, build the indexes after 'explain sql' ;)
리눅스 환경에서 하나의 process 내에서 최대로 생성할 수 있는 pthread 갯수 확인하는 간단한 툴의 소스.
아름답지 못한 코드이므로 충분한 배려가 필요.
These are the source of the utility to find out the max pthread count on Linux.
Please consider not-beautiful prototyping ;)
Test Result
goodgene@haneul:~/tmp$ !./
./max_thread 10
ret = 12, Cannot allocate memory
default stack size : 8388 KB
goodgene@haneul:~/tmp$ ./max_thread 1
ret = 12, Cannot allocate memory
default stack size : 8 MB
applied stack size : 1 MB
total created threads num [3054]
goodgene@haneul:~/tmp$ ./max_thread 10
ret = 12, Cannot allocate memory
default stack size : 8 MB
applied stack size : 10 MB
total created threads num [305]
goodgene@haneul:~/tmp$ ./max_thread 100
ret = 12, Cannot allocate memory
default stack size : 8 MB
applied stack size : 100 MB
total created threads num [30]
source
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <pthread.h>
pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
size_t stacksize = 0;
int cnt=0;
void * thread_func(void * arg)
{
pthread_mutex_lock( &lock );
++cnt;
pthread_mutex_unlock( &lock );
}
int loop( int mbsize )
{
pthread_mutex_init(&lock, NULL);
{
pthread_attr_t attr;
pthread_attr_init( &attr );
pthread_attr_getstacksize( &attr, &stacksize );
}
int n = 10000;
while (--n)
{
pthread_t thread;
pthread_attr_t attr;
pthread_attr_init( &attr );
pthread_attr_setstacksize( &attr, 1024*1024 * mbsize );
int ret = pthread_create (&thread, &attr, thread_func, NULL);
if ( ret != 0 )
{
printf("ret = %d, %s\n", ret, strerror(errno) );
return -1;
}
}
return 0;
}
int main(int argc, char *argv[] )
{
int mem = 1; /* MB */
if ( argc > 1 )
mem = atoi(argv[1]);
loop( mem );
getchar();
printf("default stack size : %d MB \n", stacksize/(1024*1024) );
printf("applied stack size : %d MB \n", mem );
printf("total created threads num [%d]\n", cnt);
}