小编Eli*_* Mx的帖子

群集与非群集主键

begin transaction;
create table person_id(person_id integer primary key);
insert into person_id values(1);
... snip ...
insert into person_id values(50000);
commit;
Run Code Online (Sandbox Code Playgroud)

这段代码在我的机器上大约需要0.9秒,并创建一个占用392K的db文件.如果我将第二行更改为,则这些数字变为1.4秒和864K

create table person_id(person_id integer nonclustered primary key);
Run Code Online (Sandbox Code Playgroud)

为什么会这样?

sqlite performance clustered-index

9
推荐指数
2
解决办法
2万
查看次数

Linux时分处理还是线程

一位教授曾在课堂上告诉我们,Windows,Linux,OS X和UNIX可以在线程而不是进程上扩展,因此即使在单个处理器上,线程也可能使您的应用程序受益,因为您的应用程序将在CPU上获得更多时间.

我尝试在我的机器上使用以下代码(只有一个CPU).

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>

pthread_t xs[10];

void *nop(void *ptr) {
    unsigned long n = 1UL << 30UL;
    while(n--);
    return NULL;
}

void test_one() {

    size_t len = (sizeof xs) / (sizeof *xs);
    while(len--)
        if(pthread_create(xs+len, NULL, nop, NULL))
            exit(EXIT_FAILURE);

    len = (sizeof xs) / (sizeof *xs);
    while(len--)
        if(pthread_join(xs[len], NULL))
            exit(EXIT_FAILURE);

}

void test_two() {

    size_t len = (sizeof xs) / (sizeof *xs);
    while(len--) nop(NULL);

}

int main(int argc, char *argv[]) {

    test_one();
//  test_two();
    printf("done\n");
    return …
Run Code Online (Sandbox Code Playgroud)

linux performance multithreading scheduling

2
推荐指数
1
解决办法
1391
查看次数