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