[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] Re: [RFA/JDWP] Event basics
From: |
Cedric Berger |
Subject: |
[cp-patches] Re: [RFA/JDWP] Event basics |
Date: |
Wed, 22 Jun 2005 21:41:39 +0200 |
User-agent: |
Mozilla Thunderbird 1.0.2 (Windows/20050317) |
Hi Keith,
Here is just a little (or big) comment about that code: I don't
know if performance is an issue or not in your code, but if
performance is an issue, then I think that the code as written
is very inefficient:
+ /**
+ * Converts this event into to a JDWP packet
+ *
+ * @param requestId the request id that wanted this event (or 0)
+ * @returns a <code>JdwpPacket</code> of the events or <code>null</code>
+ */
+ public JdwpPacket toPacket (int requestId, byte suspendPolicy)
+ {
+ JdwpPacket pkt;
+ try
+ {
+ ByteArrayOutputStream data = new ByteArrayOutputStream ();
+ DataOutputStream outStream = new DataOutputStream (data);
+
+ outStream.writeByte (suspendPolicy);
+ outStream.writeInt (1);
+ outStream.writeByte (_eventKind);
+ outStream.writeInt (requestId);
+ _writeData (outStream);
+
+ pkt = new JdwpCommandPacket (JdwpConstants.CommandSet.Event.value,
+ JdwpConstants.CommandSet.Event.Composite);
+ pkt.setData (data.toByteArray ());
+ }
+ catch (IOException ioe)
+ {
+ pkt = null;
+ }
+
+ return pkt;
+ }
You allocate here a lot of different object (data, outStream, pkt -
which each allocate
internal objects) just to generate a "JdwpPacket ", which will finally
be written to a
socket I guess (?). I think that you could rewrite the code to allocate
much less
objects during serialization/deserialization, and perform much less
copy. Actually,
if you wanted, you could use java.nio and allocate almost NO objects.
Feel free to ignore me if I'm out of context here :)
Cedric
- [cp-patches] Re: [RFA/JDWP] Event basics,
Cedric Berger <=