HDF5 - 并发、压缩和 I/O 性能 [关闭]

2024-04-04

我对 HDF5 性能和并发性有以下疑问:

  1. HDF5 支持并发写访问吗?
  2. 撇开并发因素不谈,HDF5 的性能如何?输入/输出性能 (does 压缩率影响性能)?
  3. 由于我将 HDF5 与 Python 结合使用,它的性能与 Sqlite 相比如何?

参考:

  • http://www.sqlite.org/faq.html#q5 http://www.sqlite.org/faq.html#q5
  • 可以在 NFS 文件系统上锁定 sqlite 文件吗? https://stackoverflow.com/questions/9907429/locking-sqlite-file-on-nfs-filesystem-possible
  • http://pandas.pydata.org/ http://pandas.pydata.org/

更新为使用 pandas 0.13.1

  1. No. http://pandas.pydata.org/pandas-docs/dev/io.html#notes-caveats http://pandas.pydata.org/pandas-docs/dev/io.html#notes-caveats。有多种方法可以do这个,例如让不同的线程/进程写出计算结果,然后将单个进程组合​​起来。

  2. depending the type of data you store, how you do it, and how you want to retrieve, HDF5 can offer vastly better performance. Storing in an HDFStore as a single array, float data, compressed (in other words, not storing it in a format that allows for querying), will be stored/read amazingly fast. Even storing in the table format (which slows down the write performance), will offer quite good write performance. You can look at this for some detailed comparisons (which is what HDFStore uses under the hood). http://www.pytables.org/ http://www.pytables.org/, here's a nice picture:

自 PyTables 2.3 以来,查询现在已建立索引,因此性能实际上比这要好得多。

回答你的问题,如果你想要任何类型的性能,HDF5 是最佳选择。

Writing:

In [14]: %timeit test_sql_write(df)
1 loops, best of 3: 6.24 s per loop

In [15]: %timeit test_hdf_fixed_write(df)
1 loops, best of 3: 237 ms per loop

In [16]: %timeit test_hdf_table_write(df)
1 loops, best of 3: 901 ms per loop

In [17]: %timeit test_csv_write(df)
1 loops, best of 3: 3.44 s per loop

Reading

In [18]: %timeit test_sql_read()
1 loops, best of 3: 766 ms per loop

In [19]: %timeit test_hdf_fixed_read()
10 loops, best of 3: 19.1 ms per loop

In [20]: %timeit test_hdf_table_read()
10 loops, best of 3: 39 ms per loop

In [22]: %timeit test_csv_read()
1 loops, best of 3: 620 ms per loop

这是代码

import sqlite3
import os
from pandas.io import sql

In [3]: df = DataFrame(randn(1000000,2),columns=list('AB'))
<class 'pandas.core.frame.DataFrame'>
Int64Index: 1000000 entries, 0 to 999999
Data columns (total 2 columns):
A    1000000  non-null values
B    1000000  non-null values
dtypes: float64(2)
   
def test_sql_write(df):
    if os.path.exists('test.sql'):
        os.remove('test.sql')
    sql_db = sqlite3.connect('test.sql')
    sql.write_frame(df, name='test_table', con=sql_db)
    sql_db.close()

def test_sql_read():
    sql_db = sqlite3.connect('test.sql')
    sql.read_frame("select * from test_table", sql_db)
    sql_db.close()
    
def test_hdf_fixed_write(df):
    df.to_hdf('test_fixed.hdf','test',mode='w')

def test_csv_read():
    pd.read_csv('test.csv',index_col=0)

def test_csv_write(df):
    df.to_csv('test.csv',mode='w')    

def test_hdf_fixed_read():
    pd.read_hdf('test_fixed.hdf','test')

def test_hdf_table_write(df):
    df.to_hdf('test_table.hdf','test',format='table',mode='w')

def test_hdf_table_read():
    pd.read_hdf('test_table.hdf','test')

当然YMMV。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

HDF5 - 并发、压缩和 I/O 性能 [关闭] 的相关文章

随机推荐

  • Java中易失性变量和普通变量的显示区别

    我正在尝试创建一个示例来显示易失性变量和常用变量之间的区别 例如 package main public class TestVolatile extends Thread public int l 5 public volatile in
  • UITableView reloadData 不重新加载

    我很困惑为什么 reloadData 不重新加载 tableview 它不调用numberOfRowsInSection The fetchedResultsController将新数据保存到核心数据后确实获得新行 在将新数据添加到表视图之
  • Java - 易失性的使用仅在多处理器系统中有意义?

    易失性的使用仅在多处理器系统中才有意义 这是错误的吗 我正在尝试学习线程编程 所以如果你知道任何好的文章 pdf 我喜欢提到一些关于操作系统如何工作的东西 而不仅仅是语言的语法 否 挥发性可用于多线程应用程序 它们可能会也可能不会在多个处理
  • 将 javascript 字符串转换为 html 对象 [重复]

    这个问题在这里已经有答案了 我可以将字符串转换为 html 对象吗 喜欢 string s div div var htmlObject s toHtmlObject 这样我以后就可以通过 id 获取它并对其样式进行一些更改 var ho
  • 如何在CKEditor激活时在HTML5文本区域中显示占位符属性?

    我在 HTML5 网站中有一个文本区域 具有适当的占位符 示例文本 属性 在我通过 CKEditor 添加 RichText 支持之前 它显示得很好 CKEditor GUI 正在重新创建文本区域 并且不显示其中的占位符文本 有没有办法在
  • 使用foreignObject使用D3js动态添加SVG

    working
  • 如何将文本放入可绘制对象中?

    我正在尝试动态创建一个可绘制对象 以用作自定义线性布局的背景 它需要有哈希标记之类的 没什么大不了的 而且还需要有数字来标记哈希标记的内容 就像一把尺子 我知道我可以创建文本元素并将它们放入线性布局中 然后将哈希标记放入可绘制对象中 但我希
  • extjs 树面板上下文菜单不起作用

    var menu1 new Ext menu Menu items text Open in new tab var treePanel Ext create Ext tree Panel id tree panel region cent
  • ASP.NET MVC 3 使用身份验证

    如何使用 FormsAuthentication 保存某些内容 我不想通过 URL 存储用户 ID 例如 现在我有这样的代码 UserController class HttpPost public ActionResult LogOn L
  • 如何使用 PHP 打破外循环?

    我正在寻找打破 PHP 中的外部 for foreach 循环 这可以在 ActionScript 中完成 如下所示 top for each var i MovieClip in movieClipArray for each var j
  • 使用反应钩子 getSnapshotBeforeUpdate

    如何使用 React hooks 实现 getSnapshotBeforeUpdate 提供的相同逻辑 根据React Hook 常见问题解答 https reactjs org docs hooks faq html do hooks c
  • 为什么 python docker 镜像这么大(~750 MB)?

    My Dockerfile FROM python 3 onbuild CMD python test py test py print hello world 构建图像 docker build t my test app docker
  • 如何渲染模板和布局?

    在控制器方法中 如何渲染模板和布局 Like so def new render template gt devise invitations new layout gt application unauthorized2 t2 end r
  • VS2010中关闭双击取消停靠

    我总是不小心双击 VS2010 中的选项卡并取消停靠它们 是否可以关闭此行为 注意 我正在使用 Productivity Power Tools 中的 Document Well 2010 Plus 以防产生影响 在文档选项卡上找到它以及高
  • 重命名实体框架 T4 模板生成的类名称?

    我有一个包含大量表的数据库 不幸的是这些表的命名没有任何标准约定 表名 另一个表名 还有另一个表名 垃圾表 我使用实体框架和标准 T4 代码生成模板在 C 中创建 POCO 类 是否有我可以遵循的最佳实践 让我可以合并自己的约定 在 C 应
  • Excel - VLOOKUP 与 INDEX/MATCH - 哪个更好?

    我了解如何使用每种方法 VLOOKUP or HLOOKUP vs INDEX MATCH 我寻找它们之间的差异不是出于个人喜好 而是主要在以下方面 是否有一种方法可以做到而另一种方法不能做到的事情 一般来说 哪一种更有效 或者取决于具体情
  • 如何导入具有正确类型的 Vue 类组件?

    例如 如果我有一个单文件 Vue 类组件 MyComponent vue
  • 在 jQuery .serialize() 中包含空值字段

    我正在尝试通过 jQuery post 提交表单并通过序列化表单数据 form serialize 不幸的是未选中的字段单选按钮 or 复选框没有被序列化 因此已提交 有没有办法包含所有字段 无论它们是否包含值 我想这只会影响这样的字段
  • 使用seaborn和pandas绘图防止重叠条

    我正在尝试使用 pandas 绘图来创建带有 seaborn 导入的堆叠水平条形图 我想删除条之间的空间 但也不让条重叠 这是我尝试过的 import pandas as pd import numpy as pd import seabo
  • HDF5 - 并发、压缩和 I/O 性能 [关闭]

    Closed 这个问题是无关 help closed questions 目前不接受答案 我对 HDF5 性能和并发性有以下疑问 HDF5 支持并发写访问吗 撇开并发因素不谈 HDF5 的性能如何 输入 输出性能 does 压缩率影响性能