TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Binary data processing in JavaScript

18 点作者 varunkumar将近 13 年前

7 条评论

kombine将近 13 年前
Does Int32Array look horrible only to me? What if I want an array of my own custom types - say vec2f. Do I have to use 2 Float32Array's? Javascript is a horrible language where you have the tradeoff between performance and expressibility. Seriously, this whole web development thing needs to be fixed.
评论 #4247737 未加载
azakai将近 13 年前
A few things to add to this discussion about typed arrays:<p>1. The list of support statuses does not seem to reflect that Float64Array was missing from Safari until recently, and I think might still be missing from mobile Safari.<p>2. Typed array performance of Uint32Arrays can differ from the other integer array types: unsigned int values do not fit in 31-bit signed integers, which is what most JS engines optimize ints for. This is most significant in V8 which does not use NaNboxing, so when it sees a big integer it makes it a boxed double, leading to bad performance, see for example <a href="http://code.google.com/p/v8/issues/detail?id=2097" rel="nofollow">http://code.google.com/p/v8/issues/detail?id=2097</a> Looks like the benchmarks done here did not check those values, but they happen a lot in practice with things like compiled C code.<p>3. Aside from points 1 and 2 overall typed array support and performance are predictable and good across browsers (sans IE, but hopefully with IE10). Aside from random access there is also the .set() method which lets you copy large amounts of typed data efficiently as well (which was not benchmarked here, but should basically be a memcpy so likely consistent across browsers).
评论 #4248220 未加载
mraleph将近 13 年前
Couple of things to be aware of from a V8 perspective:<p>- to make "creation" test more fair for normal arrays they should be preallocated with new Array(arraySize), if arraySize does not exceed 90000. This will ensure that you are not wasting time reallocating backing store as it grows.<p>- It has been pointed to the test author a year ago that having a single test_SMTH function and calling it with different array types causes it to become polymorphic --- which affects the generated code. V8 became much-much better in handling polymorphism of this sort, but if you'll create a test_SMTH_ARRAYTYPE for each combination of test and array type you'll see results not distorted by the polymorphism.
评论 #4247470 未加载
评论 #4247511 未加载
jacobolus将近 13 年前
This test should also add strings where the least significant byte of each character is used a byte (i.e. '\x00' = 0 up through '\xff' = 0xff). For many operations, these end up being faster than arrays of numbers.
评论 #4247318 未加载
chris_wot将近 13 年前
Jdataview handles this already. Except for Internet Explorer of course, which can't handle arrays with null characters in it. No matter what you do, IE won't let you see beyond the null char. No other browser has this issue.<p>I once pointed this out, but got a "holy edge case, Batman!" [1], and got voted to -1...<p>1. <a href="http://news.ycombinator.com/item?id=3953368" rel="nofollow">http://news.ycombinator.com/item?id=3953368</a>
tezza将近 13 年前
Hmm, I must have a differing understanding of 'support'<p><pre><code> Global user stats*:Support: 52.22% </code></pre> Yet no version of IE supports it, that ranks support close to 0% IMO.<p>I'm no IE lover, but lots of users still have it as their main browser.
评论 #4247438 未加载
评论 #4247476 未加载
评论 #4247460 未加载
评论 #4247913 未加载
chmike将近 13 年前
What is the status of the blob data type ?