rolling mean的性能对比,DolphinDB比Orca慢?

有个细节想请教下,我想测rolling mean的速度对比。在orca上,直接 df['x'].rolling(120).mean(), 运行时间是0.2ms,相关代码如下:

df = orca.read_table("dfs://xxx", "table_name")
for i in range(1000):
    vol_avg = df['Volume'].rolling(1000).mean()

然后在dolphindb database GUI上执行select mavg(x, 120) from table_name where xxx,反而是30多ms。就是先读到内存表,再对其rolling mean,如类似下面代码:

t=select *  from table_name where xxx    
timer  select mavg(x, 120) from t

这样执行稍微好一点点, 但也要10多毫秒。这DolphinDB GUI比orca接口慢这么多,是不是哪里有问题?

阅读 1.8k
1 个回答

Orca采用了惰性求值策略,某些操作不会立刻在服务端计算,而是转化成一个中间表达式,直到真正需要时才发生计算。需要触发计算时,用户应调用compute函数。df['Volume'].rolling(1000).mean()实际没有计算,要触发计算,须修改如下:

df['Volume'].rolling(1000).mean().compute()
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题