R******d 发帖数: 1436 | 1 文件中有一段需要换成新提供的内容,请问用shell/perl怎么操作?谢谢了。
举个例子,需要被替换的内容如下:
{
logic_name => 'mask',
batch_size => 10,
resource => 'rusage[myens_build1tok=11]',
memory => ['500k', '1k', '3k'],
retries => 0,
},
想要替换成的内容如下:
{
logic_name => 'mask',
batch_size => 100,
resource => 'rusage[myens_build1tok=10]',
memory => ['500MB', '1GB', '3GB'],
retries => 3,
retry_resource => 'rusage[myens_build1tok=10]', ... 阅读全帖 |
|
R******d 发帖数: 1436 | 2 bash+perl混合的捣鼓出来了,比较猥琐。
有没有可能awk和sed直接搞定?
export a=`awk '{if($0~/{/){x="";do{x=x"\n"$0}while(getline&&!/},/)};if (x~/
logic_name/&&x~/mask/){print x"\n"$0|"awk 'NF'"};x=$0}' file`
export b=`echo "{
logic_name => 'mask',
batch_size => 100,
resource => 'rusage[myens_build1tok=10]',
memory => ['500MB', '1GB', '3GB'],
retries => 3,
retry_resource => 'rusage[myens_build1tok=10]',
},"`
perl -e 'while (<>){$x.=$_}END{$x=~s/\Q$ENV{'a'}/$EN... 阅读全帖 |
|
s***e 发帖数: 793 | 3 #include
#include
/* Usage:
double start = usertime_();
// do things you want to time
double end = usertime_();
double myUserTime = end - start; // in seconds
*/
double usertime_()
{
struct rusage ruse;
getrusage (RUSAGE_SELF, &ruse);
return ((double)
(ruse.ru_utime.tv_sec + ruse.ru_utime.tv_usec / 1000000.0));
}
double systemtime_()
{
struct rusage ruse;
getrusage (RUSAGE_SELF, &ruse);
return ((double)
(ruse.ru_stime |
|
f*****p 发帖数: 235 | 4 在C下我用这个函数返回程序耗费时间
include
...
static double myclock()
{
struct rusage ru;
(void) getrusage(0,&ru);
return(ru.ru_utime.tv_sec + ru.ru_utime.tv_usec / 1.0e6);
}
现在程序移植到C++上,这个函数编译不过去。
大家在C++上用什么计时?clock()容易溢出,time(0)又不够精确。我的程序有些
部分运行时间很长。 |
|
f*****p 发帖数: 235 | 5 【 以下文字转载自 CS 讨论区 】
【 原文由 firstep 所发表 】
在C下我用这个函数返回程序耗费时间
include
...
static double myclock()
{
struct rusage ru;
(void) getrusage(0,&ru);
return(ru.ru_utime.tv_sec + ru.ru_utime.tv_usec / 1.0e6);
}
现在程序移植到C++上,这个函数编译不过去。
大家在C++上用什么计时?clock()容易溢出,time(0)又不够精确。我的程序有些
部分运行时间很长。 |
|
g****t 发帖数: 39 | 6 Hi,
I am trying to track the memory usage, especially the page faults during
allocation. I found there is a getrusage() method, which tracks page faults
and page reclaims. My questions are as follows:
1. what does "page reclaims" mean? how to interpret it? Does that mean (a) if
a page Pi was used for Ni times without page faults, then ru_minflt = \sum {
Pi * Ni} ?
reference:
http://www.fifi.org/cgi-bin/man2html/usr/share/man/man2/getrusage.2.gz
struct rusage { ...
long ru_minfl |
|