Linux script and scriptreplay(二)

前言

上一节中介绍了script和scriptreplay的用法,以及如何下载源码重编译等。 这一节中主要是用golang重写scriptreplay

script产生的timing文件格式

  • 第一行是上次输出到本次输出的间隔时间,第二行是本次输出的字节数
0.624793 107
0.111529 45
0.000538 20
0.000440 48
0.006106 3
0.000223 7
0.000419 1
0.849287 3
0.079282 7
0.091619 1
0.000479 2
0.000221 19
0.001460 7

script产生的typescript文件格式

  • 纯文本字符
Script started on Sun Apr 17 17:38:12 2016
^[[1m^[[7m%^[[27m^[[1m^[[0m                                                                                  ^M ^M^[]2;ubuntu@ubuntu: ~/share/linux/term/script^G^[]1;..x/term/script^G^M^[[0m^[[27m^[[24m^[[J^[[01;32m�~^~\  ^[[36mscript^[[00m ^[[K^[[?1h^[=l^Hls^[[?1l^[>^M^M
^[]2;ls --color=tty^G^[]1;ls^G^[[0m^[[01;32mscript.go^[[0m  test.data  test.time^M
^[[1m^[[7m%^[[27m^[[1m^[[0m

scriptreplay核心代码分析

  • 代码摘自script.c
    /* ignore the first typescript line */
    //忽略typescript的第一行
    while((c = fgetc(sfile)) != EOF && c != '\n');
    //循环读取timing文件中的数据
    for(line = 0; ; line++) {
        double delay;
        size_t blk;
        char nl;
        //读取一行数据
        if (fscanf(tfile, "%lf %zd%c\n", &delay, &blk, &nl) != 3 ||
                                                 nl != '\n') {
            if (feof(tfile))
            
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值