xpcom/tests/SizeTest02.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 // Test02.cpp
michael@0 2
michael@0 3 #include "nsIDOMNode.h"
michael@0 4 #include "nsCOMPtr.h"
michael@0 5 #include "nsString.h"
michael@0 6
michael@0 7 NS_DEF_PTR(nsIDOMNode);
michael@0 8
michael@0 9 /*
michael@0 10 This test file compares the generated code size of similar functions between raw
michael@0 11 COM interface pointers (|AddRef|ing and |Release|ing by hand) and |nsCOMPtr|s.
michael@0 12
michael@0 13 Function size results were determined by examining dissassembly of the generated code.
michael@0 14 mXXX is the size of the generated code on the Macintosh. wXXX is the size on Windows.
michael@0 15 For these tests, all reasonable optimizations were enabled and exceptions were
michael@0 16 disabled (just as we build for release).
michael@0 17
michael@0 18 The tests in this file explore more complicated functionality: assigning a pointer
michael@0 19 to be reference counted into a [raw, nsCOMPtr] object using |QueryInterface|;
michael@0 20 ensuring that it is |AddRef|ed and |Release|d appropriately; calling through the pointer
michael@0 21 to a function supplied by the underlying COM interface. The tests in this file expand
michael@0 22 on the tests in "Test01.cpp" by adding |QueryInterface|.
michael@0 23
michael@0 24 Windows:
michael@0 25 raw01 52
michael@0 26 nsCOMPtr 63
michael@0 27 raw 66
michael@0 28 nsCOMPtr* 68
michael@0 29
michael@0 30 Macintosh:
michael@0 31 nsCOMPtr 120 (1.0000)
michael@0 32 Raw01 128 (1.1429) i.e., 14.29% bigger than nsCOMPtr
michael@0 33 Raw00 144 (1.2000)
michael@0 34 */
michael@0 35
michael@0 36
michael@0 37 void // nsresult
michael@0 38 Test02_Raw00( nsISupports* aDOMNode, nsString* aResult )
michael@0 39 // m144, w66
michael@0 40 {
michael@0 41 // -- the following code is assumed, but is commented out so we compare only
michael@0 42 // the relevent generated code
michael@0 43
michael@0 44 // if ( !aDOMNode )
michael@0 45 // return NS_ERROR_NULL_POINTER;
michael@0 46
michael@0 47 nsIDOMNode* node = 0;
michael@0 48 nsresult status = aDOMNode->QueryInterface(NS_GET_IID(nsIDOMNode), (void**)&node);
michael@0 49 if ( NS_SUCCEEDED(status) )
michael@0 50 {
michael@0 51 node->GetNodeName(*aResult);
michael@0 52 }
michael@0 53
michael@0 54 NS_IF_RELEASE(node);
michael@0 55
michael@0 56 // return status;
michael@0 57 }
michael@0 58
michael@0 59 void // nsresult
michael@0 60 Test02_Raw01( nsISupports* aDOMNode, nsString* aResult )
michael@0 61 // m128, w52
michael@0 62 {
michael@0 63 // if ( !aDOMNode )
michael@0 64 // return NS_ERROR_NULL_POINTER;
michael@0 65
michael@0 66 nsIDOMNode* node;
michael@0 67 nsresult status = aDOMNode->QueryInterface(NS_GET_IID(nsIDOMNode), (void**)&node);
michael@0 68 if ( NS_SUCCEEDED(status) )
michael@0 69 {
michael@0 70 node->GetNodeName(*aResult);
michael@0 71 NS_RELEASE(node);
michael@0 72 }
michael@0 73
michael@0 74 // return status;
michael@0 75 }
michael@0 76
michael@0 77 void // nsresult
michael@0 78 Test02_nsCOMPtr( nsISupports* aDOMNode, nsString* aResult )
michael@0 79 // m120, w63/68
michael@0 80 {
michael@0 81 nsresult status;
michael@0 82 nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aDOMNode, &status);
michael@0 83
michael@0 84 if ( node )
michael@0 85 node->GetNodeName(*aResult);
michael@0 86
michael@0 87 // return status;
michael@0 88 }
michael@0 89

mercurial