Java泛型是否允许在诸如short之类的原语数组中节省内存?(Do Java generics allow for memory savings in arrays of primitives such as short?)
我做了一些谷歌搜索,但我一直无法找到这个问题的决定性答案。 为了澄清,请考虑这样的类:
public class MyContainer<T> { private T[] _store; private int _size; ... }
是否有可能通过使用
short
和int
类型的数组来实现内存节省,尽管事实上必须使用Short
和Integer
等原始包装类声明带有MyContainer
引用的变量,并且MyContainer
实例必须用这些相同的包装类创建?在我的搜索中,我发现Java编译器将类型擦除应用于泛型,但我不太确定我现在可以假设Java没有对通用类型数组进行某种优化。
有没有人有证据支持或反对这个? 提前致谢。
I've done a bit of Googling, but I've been unable to find a decisive answer to this question. For clarification, consider a class like this:
public class MyContainer<T> { private T[] _store; private int _size; ... }
Is it possible to achieve the memory savings one would get by using an array of type
short
vs.int
, despite the fact that a variable with a reference toMyContainer
must be declared with primitive wrapper classes likeShort
andInteger
, and instances ofMyContainer
must be created with those same wrapper classes?In my searches I found that the Java compiler applies type erasure to generics, but I'm not so sure that I can now assume Java does not have some sort of optimization for generically-typed arrays.
Does anyone have evidence for or against this? Thanks in advance.
原文:https://stackoverflow.com/questions/18907419
最满意答案
这个问题很古老,但仍然试图回答我的最好可能会帮助某人
虽然所有的对象和属性值都是正确的,但脚本在您的情况下会间歇性地失败原因是要加载的对象的时间变化。 您必须通过使用WaitForPageloaded()来增加两者之间的同步时间。 方法
This question is pretty old, but still try to answer my best might help someone
Script intermittently failing in your case though all the objects and property values are correct Reason is time variation of objects to load. You have to increase synctime inbetween bojects by using WaitForPageloaded(); method
相关问答
更多-
Oracle自动测试套件(Oracle Automated Testing Suit)[2023-02-02]
这个问题很古老,但仍然试图回答我的最好可能会帮助某人 虽然所有的对象和属性值都是正确的,但脚本在您的情况下会间歇性地失败原因是要加载的对象的时间变化。 您必须通过使用WaitForPageloaded()来增加两者之间的同步时间。 方法 This question is pretty old, but still try to answer my best might help someone Script intermittently failing in your case though all the ... -
这里有一篇关于iPhone自动化用户界面测试的文章,您可能会发现有用的。 这是一个小丑,但它可能会完成某些任务的工作。 请注意,我还没有尝试过。 Here's an article about automated user interface testing for the iPhone that you may find helpful. It's a little kludgy but it probably gets the job done for certain tasks. Note that ...
-
我推荐WebTest ; 它功能齐全,使用方便。 这是一个完整的工作示例,演示了一个简单的测试: from bottle import Bottle, response from webtest import TestApp # the real webapp app = Bottle() @app.route('/rest/
') def root(name): '''Simple example to demonstrate how to test Bottle routes'' ... -
使用PHP进行自动测试(Automated testing with PHP)[2022-03-12]
我使用了三种,具体取决于具体情况:SimpleTest,PHPUnit和Zend_Test(它实际上只是PHPUnit与Zend Framework一起使用的包装器)。 其中,SimpleTest真的很容易。 但是,PHPUnit提供了很多功能和灵活性。 There are three that I use, depending on the situation: SimpleTest, PHPUnit, and Zend_Test (which is really just a wrapper for P ... -
在您的Gemfile上需要ruby-debug。 如果在1.8: gem 'ruby-debug' 如果在1.9: gem 'ruby-debug19', :require => 'ruby-debug' 请注意,如果你在1.9.3上需要一些调整 。 最后,在你想调试的地方放一个debugger语句,然后运行你的测试。 它应该弹出一个控制台。 正如Amadan所说,我还建议看看pry。 Require ruby-debug on your Gemfile. If on 1.8: gem 'ruby-debu ...
-
单元测试总是自动的吗?(Is unit testing always automated?)[2021-07-31]
维基百科 : [单元测试]的实现可以从非常手动(铅笔和纸)到作为构建自动化的一部分正式化。 我不认为你会赢得你的赌注。 :( From Wikipedia: [A unit test's] implementation can vary from being very manual (pencil and paper) to being formalized as part of build automation. I don't think you will win your bet. :( -
没有办法强迫Yodlee Test Bank每次都返回相同的CAPTCHA。 由于Yodlee试图让测试银行提供更多真实的银行体验,这就是为什么它会返回新的CAPTCHA。 No there is no way to force Yodlee Test Bank to return same CAPTCHA every time. As Yodlee tries to keep the Test banks to provide more real bank experience this is why i ...
-
有关测试自动化的SO有几个主题: 哪个更适合网络测试? 记录播放自动化或编码? 用户界面测试 GUI的自动测试 我从未使用过Quick Test Pro,但我参与了几个使用不同自动化测试工具的项目; Silk Test,Rational Robot,WinRunner。 这些努力中最成功的是使用Rational Robot和RRAFS框架将应用程序更改与测试脚本隔离开来。 我们还使用STAF框架来自动化和管理我们的测试基础架构。 自动化测试是测试应用程序方面的一种很好的技术,但它并不能取代人类测试人员。 像 ...
-
一般来说,单元测试是针对开发人员的。 当开发人员编写代码时,应确保它在最常见的情况下工作。 在.NET中,我们使用NUnit,MSUnit等来测试代码和逻辑。 自动化测试通常发生在连续集成环境中测试的单元之上。 自动化测试通常由QA通过使用Selenium,Protractor,WinRunner等工具完成。 希望这可以帮助。 In general unit testing is meant for the developers. When a developer writes the code he sh ...
-
Selenium - http://seleniumhq.org/ Selenium - http://seleniumhq.org/