美文网首页
1. R语言运行效率分析_小结(1)

1. R语言运行效率分析_小结(1)

作者: 灭绝老衲 | 来源:发表于2020-02-16 21:17 被阅读0次

    小结(1)

    上述9种方法(10个月份)转换“月和季的英文名称”所花时间结果整理如下:

         type             fun         mean
    1   Month          for_if 3.252180e-01
    2   Month     for_if_else 3.054237e-01
    3   Month      for_ifelse 5.160331e-01
    4   Month      for_switch 9.307517e-02
    5   Month           which 3.935091e-01
    6   Month str_replace_all 3.372382e+00
    7   Month            join 2.467942e+00
    8   Month  ddply.parallel 7.441605e+01
    9   Month           ddply 9.836038e+00
    10 result          for_if 9.601528e-01
    11 result     for_if_else 8.065160e-01
    12 result      for_ifelse 1.007159e+00
    13 result      for_switch 7.728128e-01
    14 result           which 8.868605e-01
    15 result str_replace_all 4.431068e+00
    16 result            join 2.523177e+00
    17 result  ddply.parallel 1.939038e+01
    18 result           ddply 1.924074e+01
    19 Season          for_if 3.223124e-01
    20 Season     for_if_else 2.256315e-01
    21 Season      for_ifelse 3.162032e-01
    22 Season      for_switch 8.748225e-02
    23 Season           which 1.571115e-01
    24 Season str_replace_all 8.145484e+01
    25 Season            join 3.546876e+00
    26 Season  ddply.parallel 7.299754e+01
    27 Season           ddply 9.877732e+00
    
    #根据上述数据生成图
    data<-read.csv("/home/xh/300G/笔记/R/Book1.csv",)
    ggplot(data,aes(fun,mean,fill=type))+
      geom_col()+
      facet_wrap(~type)+
      theme(axis.text.x   = element_text(angle=90),legend.position="none")
      coord_flip()
    
    Rplot.png

    从上图可以看出,tidyverse包中的这几个函数(ddply*,str_repalce_all, join)花费的时间都明显长,而R自带的基本函数花费时间较短。

    说明

    本结果是基于随机的10个月数据统计的结果,其结果具有很大的随机性

    本结果执行的平台信息为:

    more /proc/cpuinfo | grep "model name" #CPU
    grep MemTotal /proc/meminfo  #内存
    lsb_release -a  #操作系统
    
    model name  : Intel(R) Core(TM) i3-2328M CPU @ 2.20GHz
    model name  : Intel(R) Core(TM) i3-2328M CPU @ 2.20GHz
    model name  : Intel(R) Core(TM) i3-2328M CPU @ 2.20GHz
    model name  : Intel(R) Core(TM) i3-2328M CPU @ 2.20GHz
    MemTotal:       10043876 kB
    LSB Version:    n/a
    Distributor ID: ManjaroLinux
    Description:    Manjaro Linux
    Release:    18.1.5
    Codename:   Juhraya
    

    (未完!待续……)

    相关文章

      网友评论

          本文标题:1. R语言运行效率分析_小结(1)

          本文链接:https://www.haomeiwen.com/subject/kinmfhtx.html