pinkman
V2EX  ›  问与答

求一段 Python 一代让 os x cpu 占用率飙升起来

  •  
  •   pinkman · Mar 10, 2015 · 3704 views
    This topic created in 4261 days ago, the information mentioned may be changed or developed.
    刚换了个风扇,想让cpu占用率升起来好看看新风扇转不...
    18 replies  •  2015-03-11 12:43:47 +08:00
    spoony
    spoony
    Mar 10, 2015
    1
    挽尊,Chrome开起来去优酷播一段720P就行。
    pinkman
    pinkman
    OP
    Mar 10, 2015
    2
    @spoony 现在没有网,那待会儿回家去试试 :)
    tabris17
    tabris17
    Mar 10, 2015
    3
    下个super pi啊
    20150517
    20150517
    Mar 10, 2015
    4
    开flash.......
    20150517
    20150517
    Mar 10, 2015
    5
    哦对了,是在被窝里看1080P的flash,那个飙的叫爽啊,冬天直接可以当电热毯用了
    ChanneW
    ChanneW
    Mar 10, 2015
    6
    Python 要开对应核数的进程才能跑到 100%
    zhjits
    zhjits
    Mar 10, 2015
    7
    smcFanControl 装好往 5000 转拉就行
    pinkman
    pinkman
    OP
    Mar 10, 2015❤️1
    8
    @zhjits 装好了,啦到了6500还是没有转呢?显示的温度是37
    binux
    binux
    Mar 10, 2015❤️1
    9
    cat /dev/urandom > /dev/null
    pinkman
    pinkman
    OP
    Mar 10, 2015
    10
    估计我这风扇是没有装好,现在用chrome开了4个超清视频爱奇艺、搜狐、youku、土豆,smcfancontrol显示温度71度,activity monitor中光是chrome helper的cpu占用率就是147%(这数怎么来的?会超过100%?),但风扇还是没有转...
    uniquecolesmith
    uniquecolesmith
    Mar 10, 2015
    11
    是用于给妹纸取暖?哈哈
    pinkman
    pinkman
    OP
    Mar 10, 2015
    12
    @binux 这段代码干什么的,果真有效,但也证明了风扇没有装好...
    zhjits
    zhjits
    Mar 10, 2015
    13
    @pinkman 那软件在有些机型(比如我的)上有问题,不能拉到 6500,5000 左右才行……
    bellchu
    bellchu
    Mar 10, 2015 via iPhone
    14
    Popen.wait()
    Wait for child process to terminate. Set and return returncode attribute.

    Warning This will deadlock when using stdout=PIPE and/or stderr=PIPE and the child process generates enough output to a pipe such that it blocks waiting for the OS pipe buffer to accept more data. Use communicate() to avoid that.
    ynyounuo
    ynyounuo
    Mar 10, 2015
    15
    @pinkman
    Geekbench 一下就好了
    gaocegege
    gaocegege
    Mar 10, 2015
    16
    #include <stdio.h>
    #include <time.h>
    #include <stdlib.h>
    #include <unistd.h>
    #include <errno.h>

    #define NUM_OF_CORES 8
    #define MAX_PRIME 100000

    void do_primes()
    {
    unsigned long i, num, primes = 0;
    for (num = 1; num <= MAX_PRIME; ++num) {
    for (i = 2; (i <= num) && (num % i != 0); ++i);
    if (i == num)
    ++primes;
    }
    printf("Calculated %d primes.\n", primes);
    }

    int main(int argc, char ** argv)
    {
    time_t start, end;
    time_t run_time;
    unsigned long i;
    pid_t pids[NUM_OF_CORES];

    /* start of test */
    start = time(NULL);
    for (i = 0; i < NUM_OF_CORES; ++i) {
    if (!(pids[i] = fork())) {
    do_primes();
    exit(0);
    }
    if (pids[i] < 0) {
    perror("Fork");
    exit(1);
    }
    }
    for (i = 0; i < NUM_OF_CORES; ++i) {
    waitpid(pids[i], NULL, 0);
    }
    end = time(NULL);
    run_time = (end - start);
    printf("This machine calculated all prime numbers under %d %d times "
    "in %d seconds\n", MAX_PRIME, NUM_OF_CORES, run_time);
    return 0;
    }


    From http://stackoverflow.com/a/9244508/4358533
    R4rvZ6agNVWr56V0
    R4rvZ6agNVWr56V0
    Mar 11, 2015
    17
    import multiprocessing

    def fuck_cpus():
    while True:
    print 'Fucking...'

    CPU_CORE = 4
    for i in xrange(CPU_CORE):
    multiprocessing.Process(target=fuck_cpus, args=()).start()
    R4rvZ6agNVWr56V0
    R4rvZ6agNVWr56V0
    Mar 11, 2015
    18
    shit ,缩进呢。。。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   656 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 18:33 · PVG 02:33 · LAX 10:33 · JFK 13:33
    ♥ Do have faith in what you're doing.