小编ZRJ*_*ZRJ的帖子

gperftools cpu profiler不支持多进程?

根据文档http://gperftools.googlecode.com/svn/trunk/doc/cpuprofile.html,cpu配置文件支持多进程并将生成独立的输出文件:

如果您的程序分叉,子项也将被分析(因为它们继承了相同的CPUPROFILE设置).每个过程都是单独分析的; 为了区分子配置文件与父配置文件以及彼此之间的所有子配置,所有子节点都将其process-id附加到CPUPROFILE名称.

但是当我尝试如下:

// main_cmd_argv.cpp

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <gperftools/profiler.h>

int loop(int n) {
    int sum = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            sum = i + j;
            if (sum %3 == 0) {
                sum /= 3;
            }
        }
    }
    return 0;
}

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

    printf("%s\n%s\n", getenv("CPUPROFILE"), getenv("CPUPROFILESIGNAL"));

    if …
Run Code Online (Sandbox Code Playgroud)

linux profiling google-perftools gperftools

7
推荐指数
1
解决办法
1768
查看次数

本Java代码中构造函数的顺序是什么?

这是代码,我定义了两个名为Father和Son的类,并在main函数中创建它们:

public class Test {
    public static void main(String[] args) {
        Father father = new Son();
    }
}

class Father {
    private String name = "father";
    public Father() {
        who();
        tell(name);
    }
    public void who() {
        System.out.println("this is father");
    }
    public void tell(String name) {
        System.out.println("this is " + name);
    }
}

class Son extends Father {
    private String name = "son";
    public Son() {
        who();
        tell(name);
    }
    public void who() {
        System.out.println("this is son");
    }
    public void tell(String name) …
Run Code Online (Sandbox Code Playgroud)

java

6
推荐指数
2
解决办法
365
查看次数

标签 统计

google-perftools ×1

gperftools ×1

java ×1

linux ×1

profiling ×1