Over a million developers have joined DZone.

How fast are Java Datagrams?

· Java Zone

Check out this 8-step guide to see how you can increase your productivity by skipping slow application redeploys and by implementing application profiling, as you code! Brought to you in partnership with ZeroTurnaround.

Following my article How fast are Java sockets, this article follows the same tests except for Datagrams which use UDP rather than TCP.

 

 

The timings

The tests are the same except Datagrams don't support busy waiting in Java 6 which hurts the Threaded Ping latency
UDP Pings per second 224 K/s
UDP Pings latency was 1/50/99%tile 4.1/4.2/4.7 us
Threaded UDP Pings per second 131 K/s
Threaded UDP Pings latency was 1/50/99%tile 9.8/11.0/33.2 us

Comparison

Test Threaded ThroughputTypical latency
Datagram Pingno224 K/s 4.2 μs
Socket Pingno170 K/s 5.8 μs
Datagram Pingyes131 K/s11.0 μs
Socket Pingyes235 K/s8.5 μs

The Code

DatagramPingTest.java

From http://vanillajava.blogspot.com/2011/07/how-fast-are-java-datagrams.html

The Java Zone is brought to you in partnership with ZeroTurnaround. Check out this 8-step guide to see how you can increase your productivity by skipping slow application redeploys and by implementing application profiling, as you code!

Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}