CPU huffman压缩更快第一次执行后? [英] CPU huffman compression faster after first execution?

查看:169
本文介绍了CPU huffman压缩更快第一次执行后?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在C ++中构建了一个CPU实现的Huffman编码。我还在CUDA中构建了一个GPU版本,以便比较时间,但是我在测试CPU的时间时遇到了一个问题:

I've recently constructed a CPU implementation of Huffman encoding in C++. I've also constructed a GPU version in CUDA in order to compare times, but I've come across a problem when testing the CPU's times:

当压缩测试通过压缩大文件,例如97MB的文本文件,几乎每个字母表中的字母和各种其他ascii字符,我的CPU实现将需要大约8.3秒的第一次执行。之后,时间显着下降到1.7秒。注意:我只是计算CPU的频率计数,而不是字符串的编码和写入文件。

When stress testing by compressing large files, for instance a 97mb text file with almost every letter in the alphabet and various other ascii characters, my CPU implementation will take approximately 8.3 seconds the first time it executes. After that, the time drops significantly to 1.7 seconds. NOTE: I'm only timing the CPU's counting of the frequency, not the encoding of the string and writing to a file.

有什么想法如何?我正在关闭所有文件指针,并且不应该缓存任何我知道的东西。

Any ideas how this could be? I'm closing all file pointers and shouldn't be caching anything as far as I know.

让我知道是否需要任何源代码。 >

Let me know if any source code is needed, thanks.

推荐答案

首次运行后,文件内容由系统缓存(并由所有进程共享),因此下次运行从内存中读取文件。

After the first run the file content is cached by the system (and is shared by all processes), so the next run you are actually reading the file from memory.

这篇关于CPU huffman压缩更快第一次执行后?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆