- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是一个有点奇怪的情况。我知道真正的解决方案是深入开源并修复错误。但是请逗我...
我正在使用 GELF 标准将日志消息发送到 logstash
(版本 5.0.0)。遗憾的是,logstash
的 GELF 解析器(Ruby gem gelfd:0.2.0
)can only parse compressed messages .
对我来说阻力最小的方法就是压缩我的每条日志消息。即使它是 100 字节的消息。不会有有意义的大小优势(无论哪种方式都适合单个 UDP 数据报,并且其目的地是本地主机),实际上文件 may become larger .
我担心我的应用程序会执行大量不必要的压缩 — 而我的 logstash
服务器会执行大量不必要的解压缩 — 只是为了解决 gelfd
中的这个错误>.
compression algorithms supported by GELF是 GZIP 和 ZLIB。
使用这些算法:尝试压缩然后解压缩一个小文件的计算成本有多大?
编辑:很抱歉在我自己没有做任何研究的情况下提交这个问题。作为忏悔:我现在已经提交了我自己的基准测试结果作为答案。
最佳答案
我已经为 GZIP 编写了一个基准测试脚本。
不完全代表:
尽管如此,它还是提供了一个有用的启发。
plain="2016-11-09 20:56:02,469 ERROR [main] c.s.HelloExample - Something wrong with customer 'CUS-123e4567-e89b-12d3-a456-42665544'"
echo "Log message which we are using for this test is:"
echo $plain
echo "Time taken to echo this string 10,000 times:"
time for a in $(seq 1 10000);
do
echo $plain > /dev/null
done
echo "Time taken to echo and compress this string 10,000 times:"
time for a in $(seq 1 10000);
do
echo $plain | gzip -cf > /dev/null
done
echo "Time taken to echo, compress and decompress this string 10,000 times:"
time for a in $(seq 1 10000);
do
echo $plain | gzip -cf | gzip -cfd > /dev/null
done
测量结果如下:
Log message which we are using for this test is:
2016-11-09 20:56:02,469 ERROR [main] c.s.HelloExample - Something wrong with customer 'CUS-123e4567-e89b-12d3-a456-42665544'
Time taken to echo this string 10,000 times:
real 0m1.940s
user 0m0.591s
sys 0m1.333s
user+sys 0m1.924s
Time taken to echo and compress this string 10,000 times:
real 0m22.028s
user 0m11.309s
sys 0m17.325s
user+sys 0m28.634s
Time taken to echo, compress and decompress this string 10,000 times:
real 0m22.983s
user 0m18.761s
sys 0m27.322s
user+sys 0m46.083s
[Finished in 47.0s real time]
User+sys shows how much CPU time was used ;这是计算计算密集程度的重要一点。
因此,与仅回显原始字符串相比,压缩需要大约 14.9 倍的计算量。
压缩 + 解压缩比仅回显原始字符串需要多 24.0 倍的计算。这仅比压缩多 1.6 倍的计算量。
结论:
注意:实际上,该测试可能一直在测量 gzip 可执行文件的启动和清理成本。我不确定这些是否重要,但我们可以肯定地看到它是一个线程应用程序 (user + sys < real)。所以我可以想象启动 pthreads 等设置开销。
对于 GZIP 的时间复杂度与输入大小的关系,我无法找到任何结论性的答案。但知道会很有趣。
关于compression - 对微小的有效负载(<100 字节)使用压缩和解压缩的成本是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40515628/
我有点想做 the reverse of this. 我不想解压缩并将收集文件添加到 S3 应用户要求: 生成一堆xml文件 使用一些图像(托管在 s3 上的预先存在的图像)压缩 xml 文件 下载
将此添加到域的虚拟主机后 AddOutputFilterByType DEFLATE application/javascript text/javascript text/css 响应头不包含任何内
在 Apache Im 中,通过将以下内容添加到我的 .htaccess 文件来启用输出压缩: # compress text, html, javascript, css, xml: AddOutp
是否可以以压缩格式将请求数据从浏览器发送到服务器? 如果是,我们该怎么做? 最佳答案 压缩从浏览器发送到服务器的数据是不受 native 支持 在浏览器中。 您必须找到一种解决方法,使用客户端语言(可
我正在寻找可以压缩JavaScript源代码的工具。我发现一些网络工具只能删除空格字符?但也许存在更好的工具,可以压缩用户的函数名称、字段名称、删除未使用的字段等。 最佳答案 经常用来压缩JS代码的工
使用赛马博彩场景,假设我有许多单独的投注来预测比赛的前 4 名选手 (superfecta)。 赌注如下... 1/2/3/4 1/2/3/5 1/2/4/3 1/2/4/5 1/2/5/3
我是一名实习生,被要求对 SQL 2008 数据压缩进行一些研究。我们想将 Outlook 电子邮件的几个部分存储在一个表中。问题是我们想将整个电子邮件正文存储在一个字段中,然后又想压缩它。使用 Ch
我目前有一个系统,用户可以在其中上传 MP4 文件,并且可以在移动设备上下载该文件。但有时,这些视频的大小超过 5MB,在我国,大多数人使用 2G。因此,下载大型视频通常需要 15-20 分钟。 有什
假设我有一个带有类型列的简单文档表: Documents Id Type 1 A 2 A 3 B 4 C 5 C 6 A 7 A 8 A 9 B 10 C 用户
我有一个较大字符串中的(子)字符串位置的 data.frame。数据包含(子)字符串的开头及其长度。可以很容易地计算出(子)字符串的结束位置。 data1 start length end #>
我想知道是否 文件加密算法可以设计成它也可以执行文件压缩的事件(任何活生生的例子?)。 我也可以将它集成到移动短信服务中,我的意思是短信吗? 另外我想知道二进制文件...如果纯文本文件以二进制编码
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 7年前关闭。 Improve thi
我们有几个具有大量 JavaScript 的 Java 项目,目前我们使用的是旧版本的 YUICompressor (2.4.2)。然而,我在这篇博文中发现 YUICompressor 正在 depr
从之前关于尝试提高网站性能的文章中,我一直在研究 HTTP 压缩。我读过有关在 IIS 中设置它的信息,但它似乎是所有 IIS 应用程序池的全局事物,我可能不允许这样做,因为还有另一个站点在其上运行。
我有一个 REST 服务,它返回一大块 XML,大约值(value) 150k。 例如http://xmlservice.com/services/RestService.svc/GetLargeXM
我正在尝试获取一个简单的 UglifyJS (v2.3.6) 示例来处理压缩。 具体来说,“未使用”选项,如果从未使用过,变量和函数将被删除。 这是我在命令行上的尝试: echo "function
我正在开发一个项目,如果我的磁盘出现问题,我将在使用 ZLIB 压缩内存块后将其发送到另一个磁盘。然后我计划下载该转储并用于进一步调试。这种压缩和上传将一次完成一个 block - 比如说 1024
LZW 压缩算法在压缩后增加了位大小: 这是压缩函数的代码: // compression void compress(FILE *inputFile, FILE *outputFile) {
我的问题与如何在 3D 地形上存储大量信息有关。这些信息应该是 secret 的,因为它们非常庞大,也应该被压缩。我选择了文件存储,现在我想知道将对象数据加密/压缩(或压缩/加密)到文件的最佳做法。
我使用以下代码来压缩我的文件并且效果很好,但我只想压缩子文件夹而不是在压缩文件中显示树的根。 public boolean zipFileAtPath(String sourcePath, Strin
我是一名优秀的程序员,十分优秀!