The Artima Developer Community
Sponsored Link

Java Buzz Forum
Brian Coyner: Throwing Null

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Weiqi Gao

Posts: 1808
Nickname: weiqigao
Registered: Jun, 2003

Weiqi Gao is a Java programmer.
Brian Coyner: Throwing Null Posted: Apr 20, 2007 11:20 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Weiqi Gao.
Original Post: Brian Coyner: Throwing Null
Feed Title: Weiqi Gao's Weblog
Feed URL: http://www.weiqigao.com/blog/rss.xml
Feed Description: Sharing My Experience...
Latest Java Buzz Posts
Latest Java Buzz Posts by Weiqi Gao
Latest Posts From Weiqi Gao's Weblog

Advertisement

Brian Coyner: Did you know that you can throw null?

Go read Brian's post now.

Done? Good.

When I ran Brian's example on a three-year-old WinXP Pro SP2 Pentium 4 3.2GHz, 2.5 GB RAM, Java 6, I get the following results:

[weiqi@gao]$ java NullExceptionTest # throwNull 
Average Time (nano): 18022
Average Time (nano): 17965
Average Time (nano): 19184
Average Time (nano): 17377
Average Time (nano): 16760
Average Time (nano): 16423
[weiqi@gao]$ java NullExceptionTest # throwNullPointerException
Average Time (nano): 3884
Average Time (nano): 3327
Average Time (nano): 2980
Average Time (nano): 2669
Average Time (nano): 3024
Average Time (nano): 2724

Throwing null is still more expensive than throwing a new NullPointerException, however the ratio is 5.68 rather than the 45 on Brian's machine.

Now I'm curious how the numbers will respond to arch/os/runtime variations.

Read: Brian Coyner: Throwing Null

Topic: The Coolest GMail Extension Previous Topic   Next Topic Topic: Sun has posted an early access release of the Java Wireless Toolkit 2.5.1 for CLDC.

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use