Changeset 56689 in webkit for trunk/JavaScriptCore/qt/tests


Ignore:
Timestamp:
Mar 28, 2010, 3:43:05 AM (15 years ago)
Author:
[email protected]
Message:

2010-03-28 Kent Hansen <[email protected]>

Reviewed by Simon Hausmann.

[Qt] Add API for reporting additional memory cost of JavaScript objects
https://bugs.webkit.org/show_bug.cgi?id=36650

  • qt/api/qscriptengine.cpp: (QScriptEngine::reportAdditionalMemoryCost):
  • qt/api/qscriptengine.h:
  • qt/api/qscriptengine_p.h: (QScriptEnginePrivate::reportAdditionalMemoryCost):
  • qt/tests/qscriptengine/tst_qscriptengine.cpp: (tst_QScriptEngine::reportAdditionalMemoryCost):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/qt/tests/qscriptengine/tst_qscriptengine.cpp

    r56686 r56689  
    3939    void evaluate();
    4040    void collectGarbage();
     41    void reportAdditionalMemoryCost();
    4142    void nullValue();
    4243    void undefinedValue();
     
    7374    engine.collectGarbage();
    7475    QCOMPARE(foo.call().toString(), QString::fromAscii("pong"));
     76}
     77
     78void tst_QScriptEngine::reportAdditionalMemoryCost()
     79{
     80    // There isn't any easy way to test the responsiveness of the GC;
     81    // just try to call the function a few times with various sizes.
     82    QScriptEngine eng;
     83    for (int i = 0; i < 100; ++i) {
     84        eng.reportAdditionalMemoryCost(0);
     85        eng.reportAdditionalMemoryCost(10);
     86        eng.reportAdditionalMemoryCost(1000);
     87        eng.reportAdditionalMemoryCost(10000);
     88        eng.reportAdditionalMemoryCost(100000);
     89        eng.reportAdditionalMemoryCost(1000000);
     90        eng.reportAdditionalMemoryCost(10000000);
     91        eng.reportAdditionalMemoryCost(-1);
     92        eng.reportAdditionalMemoryCost(-1000);
     93        QScriptValue obj = eng.evaluate("new Object");
     94        eng.collectGarbage();
     95    }
    7596}
    7697
Note: See TracChangeset for help on using the changeset viewer.