VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/xpcom/tests/SizeTest02.cpp@ 62330

Last change on this file since 62330 was 1, checked in by vboxsync, 55 years ago

import

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette