A query on a small benchmark test.

I ran a small code snippet from a book I am reading and was surprised by the results. The code calls an empty method and also a method with a variables assignment as the body. I figured the empty method call should have been quicker but it is consistently the other way round. Here is the code I ran:
class MethodBenchmark extends Benchmark {
    void benchmark() {
         int x = 2+2+2+2+2+2+2;
    //899543099 as above
    //923825235 empty body
    //925611216 empty body
    //884589242 as above
    public static void main(String[] args) {
        int count = 100000000;
        long time = new MethodBenchmark().repeat(count);
        System.out.println(count + " methods in " +
                           time + " nanoseconds");
abstract class Benchmark {
    abstract void benchmark();
    public final long repeat(int count) {
        long start = System.nanoTime();
        for (int i = 0; i < count; i++)
            benchmark();
        return (System.nanoTime() - start);
}What is the reason for this?
By the way this is not a "Java is broke thread" I am sure there is a logical answer to this.

I just came across this on Google.
http://java.sun.com/docs/hotspot/HotSpotFAQ.html#benchmarking_method
Here is an extract
Code is generated into memory and executed from there. The way the code is laid out in memory makes a big difference in the way it executes. In this example on my machine, the loop that claims to call the method is better aligned and so runs faster than the loop that's trying to figure out how long it takes to run an empty loop, so I get negative numbers for methodTime-loopTime.
Which would mean I was running the same code each time, the compiler would have ignored the body because it was dead and I was essential running an empty method body both times, but why the change?
But it also says this
The HotSpot compiler is smart enough not to generate code for dead variables.
In the method above, the local variable is never used, so there's no reason to compute its value. So then the method body is empty again and when the code gets compiled (and inlined, because we removed enough code to make it small enough for inlining) it turns into an empty method again.
I guess an inlined empty method in memory must be quicker than an empty method from the beginning.
Message was edited by:
helloWorld

Similar Messages

  • Poor performance by Matlab and Windows benchmark tests

    Hello
    I have a Lenovo Thinkpad W520 with Windows 7 64bit installed. Compared to other Notebooks with comparable hardware, my Lenovo is very slow. To prove my thought, I carried through a Matlab (64bit) benchmark test and the Windows 7 benchmark test. In both tests, my Lenovo was worse than the other notebooks. During the tests I set the Power Manager to performance and activated the Lenovo turbo boost.
    Now I want to ask, if there are any settings, perhaps in the bios, to speed the laptop up? Or why result such a bad performance although the hardware is very good?
    Thanks for your help
    Solved!
    Go to Solution.

    Thank you very much for your reply!
    I dated up the BIOS from version 1.27 to 1.32. Now the benchmark tests all look great!!
    Thanks

  • Performance issues in bootcamp with Passmark benchmark test

    I wonder if anyone can shed some light on this
    I've got a Win XP 32bit SP3 installed on bootcamp. When i test this using the passmark benchmark test (latest version on a 30 day trial). I get poor CPU performance. I am running a 2.53 13" MacBook Pro. I can compare the results with other peoples results from the passmark database, by same CPU and also by other macbooks.
    My scores are nearly half what other similar macbooks are showing in CPU Math, which is quite a difference.
    So i wonder what's up, and how can i check it further? Half sounds like only one CPU running.
    I've compared VMFusion and Bootcamp as well and there's not much in them, both results are showing around half the performance. (This is Fusion running the bootcamp install. A free windows install in Fusion shows slightly better results but not that much)
    Any pointers or help would be great, for example is there some way under OS X i can check the performance of the macbook as a baseline?
    Is there something i've not done whilst installing Win XP through book camp?
    thanks in advance!
    paul

    Maybe until software catches up and is patched to work with Intel 3000 plus 6970M.
    Apple did get early jump on Sandy Bridge +
    Can't find the thread from someone else (thanks for making searching threads so clumbersome)
    AMD Mobility
    http://support.amd.com/us/gpudownload/windows/Pages/radeonmob_win7-64.aspx
    And for Nvidia 320M users:
    http://www.nvidia.com/object/notebook-win7-winvista-64bit-275.27-beta-driver.htm l
    3DMark06 will almost surely I suppose need a patch.
    I'd hit the web sites for PC laptop gaming if you can.
    http://www.bing.com/search?q=6970M+3DMark06
    http://www.notebookcheck.net/Intel-HD-Graphics-3000.37948.0.html
    This should be right now your alley -
    http://forums.macrumors.com/showthread.php?t=1101179&page=2
    http://www.bing.com/search?q=6970M+with+Intel+3000+graphics
    Most of this type stuff is at your fingertips with a little searching.

  • I'm using Entourage 2008 v 12.3.5 and lost ability to SEND.  Tried many small email tests.  Server continues to leave time out message.  "An operation on the server timed out. The server may be down, overloaded, or there may be too much net traffic.

    I'm using Entourage 2008 v 12.3.5 and lost ability to SEND.  Tried many small email tests.  Server continues to leave time out message.  "An operation on the server timed out. The server may be down, overloaded, or there may be too much net traffic."  Comcast tells me server is not down all other network activity is fine.  WHat's up with this?

    Starting earlier today, this also became my problem - can receive but not send in Entourage. The account settings are correct in Entourage - I even created a new account.  My Mac running 10.7.5 won't read the original Office : MAC 2008 disk, so I can't do a fix or reinstall from the disk.
    This is not an issue if I log onto the Comcast site.
    And so, I started using Mail but, unlike Entourage, Mail won't import my Entourage info.
    Argh...  :-(

  • Queries for benchmark test

    Hi. I'm creating a benchmark for Oracle 10g. I'd like to know if anybody knows a site, or a documentation, or information about all the queries that are most used in benchmark tests and how many record I have to apply this tests to have a good test. I appreciate!

    You may find this posting helpful for using free benchmark tool for oracle.
    http://www.oraclepoint.com/topic.php?filename=166&extra=page%3D1 (register and then log in because it's only available for members.)
    There are step-by-step installation guide and sample report of TPC-C.
    Hope it helps.

  • Benchmark tests!!!!  Galaxy S3 vs iPhone5 !!!!!!

    Benchmarks were run between the two phone:  the 4 tests were (1) Speedtest.net, (2) Geekbench, (3) Sunspider JavaScript Benchmark, and (4) GL Benchmark.  The link below has the Youtube video running all test!  MUST SEE!!! iPhone 5 zips past Galaxy SIII in Speed Test http://news.yahoo.com/iphone-5-zips-past-galaxy-iii-speed-test-132936436.html iPhone 5 Humiliates Galaxy SIII in Drop Test http://news.yahoo.com/iphone-5-humiliates-galaxy-iii-drop-test-video-154148011.html iPhone 5's A6 processor found to have a dual-core CPU, triple-core GPU http://news.yahoo.com/iphone-5-a6-processor-found-dual-core-cpu-220506025.html

    <In an effort to avoid board clutter, this thread will be closed. Please see any replies in iPhone 5 proven faster than Galaxy SIII with benchmark tests!!!!!.>

  • About: BOEXI3.1 Sizing and Benchmark test

    Hi Guru,
         Does any of you have the Sizing Guide or Sizing Tool for BOE XI R3.1?
         And I also need some benchmark test paper from 3rd party organization or other customers.
    Thanks.
    Michael Gao

    What error messages do you get when you run them?
    Have you tried compiling them with the "-deprecation" option
    this can provide more information (when compiling) about things that
    are no longer supported. Although if you arn't getting any errors
    on compilation that probably isn't going to be your problem.
    matfud

  • F7  query for capital & small letters

    I have form has 3 fields (item, item_desc, location) , I want to do F7 & F8 to do searching in those 3 fields, but I want to do it using capital and small letter , so the client can CLICK F7 and write any word with capital and small letter mixing and click F8 then get all the item with he/she wrote.
    My form now doing querying just if I write exactly the same word, but I want it as client write as mixing capital with small letter and sytem can caught it.

    If I'm guessing correctly on you question : on the Item there is a "Case Insensitive Query" property which you can set to Yes to so that upper, lower or mixed case queries will match ok.
    If you are querying a large table be aware that database indexes may not be used on these columns and you may have to cater for that (with a function based index on the columns in the database)
    HTH
    Steve

  • Error when running PPBM4 BENCHMARK test

    Please check out the problem in the following short video:
    http://www.youtube.com/watch?v=OUeBdg6oFBQ
    Thanks
    Rowby

    I ran the test 2 more times.
    I forgot to have my scratch files go to a different drive.
    I ran the test again the same as I ran the other 2 tests with all the files on ONE drive and here are the results.
    Powered by DESIGN,   Personal or Computer ID
    Gateway,  Computer Manufacturer
    FX6840,   Computer Model
    62.5,  secs Total Benchmark Time
    7.3,  secs AVI  Encoding Time
    32.2,  secs MPEG Elapsed Time
    23,  secs Rendering Time
    INTEL,    CPU Manufacturer
    i7-860,    CPU Model
    2.80 GHz,    GHz CPU speed
    1,    Number of CPU chips
    4,    Total Number of Cores
    8 GB,    GB RAM
    5.0.1,    APP Version PPBM4 DV
    Win 7 64 Home,    OSVersion
    SATA,    OS Disk Interface
    1 TB,    GB OS Disk Capacity
    7200,    OS Disk Speed
    SATA,    Project Disk Interface
    1 TB,    GB Project Disk Capacity
    7200,    Project Disk Speed
    SATA,    Preview Disk Interface
    1 TB,    GB Preview Disk Capacity
    7200,    Preview Disk Speed
    SATA,    Output Disk Interface
    1 TB,    GB Output Disk Capacity
    7200,    Output Disk Speed
    Radeon HD 5770,    Graphics Board
    Best Buy Special,    Comment
    I then went in and changed the Scratch Disks from SAME AS PROJECT on all 4 options to a different hard drive.
    Captured Video
    Captured Audio
    Video Previews
    Audio Previews
    Here are the scores with that changes.   It got worse.
    Powered by DESIGN,   Personal or Computer ID
    Gateway,  Computer Manufacturer
    FX6840,   Computer Model
    87.4,  secs Total Benchmark Time
    30.6,  secs AVI  Encoding Time
    33.8,  secs MPEG Elapsed Time
    23,  secs Rendering Time
    INTEL,    CPU Manufacturer
    i7 860,    CPU Model
    2.80,    GHz CPU speed
    1,    Number of CPU chips
    4,    Total Number of Cores
    8,    GB RAM
    5.0.1,    APP Version PPBM4 DV
    Win 7 64,    OSVersion
    SATA,    OS Disk Interface
    1 TB,    GB OS Disk Capacity
    7200,    OS Disk Speed
    SATA,    Project Disk Interface
    1 TB,    GB Project Disk Capacity
    7200,    Project Disk Speed
    SATA,    Preview Disk Interface
    1 TB,    GB Preview Disk Capacity
    7200,    Preview Disk Speed
    SATA,    Output Disk Interface
    1 TB,    GB Output Disk Capacity
    7200,    Output Disk Speed
    Radeon HD 5770,    Graphics Board
    Best Buy Special,    Comment
    I thought it would be faster ?
    GLenn

  • Testing an ISA Server Rule, the recursive query to other DNS Servers test fails

    Hello,
    I am trying to configure the following infrastructure with ISA Server 2006 and two W2003 servers (called "Server1" and "Server2") . "Server1" is a domain controller, and in
    "Server2" is the ISA Server installed, which also has
    attached two network Ethernet cards, one called "Internal Ethernet Card", and the other one called
    "External Ethernet Card".
    The infrastructure would be:  "Internal Ethernet Card"---- ISA Server ----"External Ethernet Card"---"Router"----"Internet"
    "Internal Ethernet Card" manages the internal package traffic of the infrastructure, the network segment which belongs is isolated from what we could called the Outbound traffic, which is linked to a router. "Internal Ethernet Card" it`s
    a virtual network.
    "Internal Ethernet Card" feature configuration is the following:
    - IP address: 192.168.3.3
    - Subnet Mask: 255.255.255.0
    - DHCP Enabled: No
    - DNS Server: 192.168.3.1 (Must point to the DC "Server1" which has the DNS Service installed)
    - Default Gateway:  None  (because doesnt point to outside)
    - Primary WINS Server: 192.168.3.1  
    The "External Ethernet Card" provides, the outbound connection, and this card is connected to the physical router.
    It`s feature configuration is the following:
    - IP address: 192.168.1.50
    - Subnet Mask: 255.255.255.0
    - DHCP Enabled: No
    - Default Gateway: 192.168.1.1
    - DNS Servers: 192.168.3.1 (Must point to the DC "Server1" which has the DNS Service installed)
    After configuring the network cards, I create the following rule in the ISA Server to allow the traffic towards outside from the server and the clients which have joined to the domain:
    Action: Allow.  Protocol: DNS.  From:"Server2".  To : External.  Condition: All Users
    After applying the changes to update the configuration, I enter in the Dns Server of "Server1" and in the "Monitoring" tab, I run a "recursive query to other DNS Servers" but fails.
    Only works the "simple query against this DNS Server".
    I don`t know why fails, but I`m stucked on this issue, because in the "Server1" DNS Server, in the "domain forward IP address list", I have added two DNS addresses which work OK.
    I would appreciate some help to solve this issue.
    Thanks
    Regards 

    Hello Ms. Long, 
    Yes, you are right. In the Server1 is configured the DNS server, to use forwarders whose are set in the field "Selected domain`s forwarder IP address list", two DNS address numbers obtained from "Open DNS", which work well.
    There is no DNS Server linked to the External NIC.
    The Server1 belongs to a private network configured as "VMnet3", which it is set as follows:
    IP address: 192.168.3.1
    Subnet Mask: 255.255.255.0
    Default Gateway: 192.168.3.3
    DNS Server: 192.168.3.1
    I have tried to test your suggested idea:
    > set d2
    > google.com
    Server:  srv-dcfs-01.dominio.local
    Address:  192.168.3.1
    SendRequest(), len 42
        HEADER:
            opcode = QUERY, id = 2, rcode = NOERROR
            header flags:  query, want recursion
            questions = 1,  answers = 0,  authority records = 0,  additional = 0
        QUESTIONS:
            google.com.dominio.local, type = A, class = IN
    Got answer (113 bytes):
        HEADER:
            opcode = QUERY, id = 2, rcode = NXDOMAIN
            header flags:  response, auth. answer, want recursion, recursion avail.
            questions = 1,  answers = 0,  authority records = 1,  additional = 0
        QUESTIONS:
            google.com.dominio.local, type = A, class = IN
        AUTHORITY RECORDS:
        ->  dominio.local
            type = SOA, class = IN, dlen = 46
            ttl = 3600 (1 hour)
            primary name server = srv-dcfs-01.dominio.local
            responsible mail addr = hostmaster
            serial  = 41
            refresh = 900 (15 mins)
            retry   = 600 (10 mins)
            expire  = 86400 (1 day)
            default TTL = 3600 (1 hour)
    SendRequest(), len 28
        HEADER:
            opcode = QUERY, id = 3, rcode = NOERROR
            header flags:  query, want recursion
            questions = 1,  answers = 0,  authority records = 0,  additional = 0
        QUESTIONS:
            google.com, type = A, class = IN
    DNS request timed out.
        timeout was 2 seconds.
    timeout (2 secs)
    SendRequest failed
    *** Request to srv-dcfs-01.dominio.local timed-out
    As you can see highlighted in bold, the problem remains in the "recursive query to other DNS Servers" check.
    Maybe is better to put the issue on the "Windows Server General Forum" , because the issue has not nothing in common with the ISA Server, dont you?
    Thanks
    Best regards

  • IPhone 5 proven faster than Galaxy SIII with benchmark tests!!!!!

    Thought this might be useful to people thinking about the iPhone 5---speed test AND real world drop tests!!! iPhone 5 zips past Galaxy SIII in Speed Test http://news.yahoo.com/iphone-5-zips-past-galaxy-iii-speed-test-132936436.html iPhone 5 Humiliates Galaxy SIII in Drop Test http://news.yahoo.com/iphone-5-humiliates-galaxy-iii-drop-test-video-154148011.html iPhone 5's A6 processor found to have a dual-core CPU, triple-core GPU http://news.yahoo.com/iphone-5-a6-processor-found-dual-core-cpu-220506025.html

    LOL...nothing...just been trying like hell to find some speed test..and stumbled across these plus the drop test....the phone is a pretty hot topic and thought that I would provide some objective facts rather than the normal colorful metaphor bashing that seems to be the norm on alot of forums.  Rather than just saying what I think, I think is more important to see and read objective facts and then let the viewer draw his or her own conclusion. 

  • Immediate Small Project - Test Bench Data Acquisition, Processing, & Basic Automation

    I am need of a Labview Programmer to assist immediately on a test bench setup.  The sepcifics are as follows....
    Acquire data from 16 LVDT with 4-20 mA signal simultaneously at a single time.
    Convert to distance using bit resolution conversion.
    Calculate best fit plane for data points, given a (x,y) location of each sensor, where the signal is the z coordinate.
    Calculate properties of part with distance from best fit plane to individual LVDT points and report to LabView SPC.
    Trigger 24 VDC I/O to actuate pneumatic solenoids with timing delays to provide throughput through test station.
    Trigger data acquisition when part is present in test area of machine.
    Requested completion time is one week.  Project is located in Clover, SC outside of Charlotte, NC.  Remote work is acceptable.
    Please email me if interested in project. [email protected]

    I am need of a Labview Programmer to assist immediately on a test bench setup.  The sepcifics are as follows....
    Acquire data from 16 LVDT with 4-20 mA signal simultaneously at a single time.
    Convert to distance using bit resolution conversion.
    Calculate best fit plane for data points, given a (x,y) location of each sensor, where the signal is the z coordinate.
    Calculate properties of part with distance from best fit plane to individual LVDT points and report to LabView SPC.
    Trigger 24 VDC I/O to actuate pneumatic solenoids with timing delays to provide throughput through test station.
    Trigger data acquisition when part is present in test area of machine.
    Requested completion time is one week.  Project is located in Clover, SC outside of Charlotte, NC.  Remote work is acceptable.
    Please email me if interested in project. [email protected]

  • Problem in Testing the Query Template

    Hi All,
      I created mysql connection in the Dataservers and connection status was successful.we created FixedQuery(Fixed Query is SQLQuery Template type) in the query template editor.when i am trying to test the sql query "select * from emp" it is not displaying any result template.But sql query is working fine we tested in MYSQL server console.
    please do the need ful
    Regards
    Srikanth M

    Hi,
    I written fixed sql query(select * from emp) in the  query tab,When i select the "Test" button one window is opening ,text/html selected  and submited "OK" button .It is not opening any result template in the browser.
    Regards
    Srikanth

  • Query works in Test mode but fails with transient failure

    Hi,
    I have a query that works well while testing with input json data. However, when the job is started the query fails with transient failure.
    I have two eventhub input sources input1 and input2. I also have a reference data source in a blob, ref.
    The query is 
    WITH nameone AS(
    SELECT ref.field1 as field1,ref.field2 as field2,MIN(input1.datetimestamp) AS datetimestamp,avg(input1.value) as value FROM input1 TIMESTAMP BY datetimestamp JOIN ref ON ref.field1 = input1.field1 GROUP BY ref.field1,tumblingwindow(second,30)
    ), nametwo AS(
    SELECT ref.field1 as field1,ref.field2 as field2,MIN(input2.datetimestamp) AS datetimestamp,avg(input2.value) as value FROM input2 TIMESTAMP BY datetimestamp JOIN ref ON ref.field1 = input2.field1 GROUP BY ref.field1,tumblingwindow(second,30)
    SELECT field1, field2,datetimestamp,value from nameone
    UNION
    SELECT field1, field2,datetimestamp,value from nametwo
    Thanks

    I solved the problem. 
    The issue was in conversion of incoming data to write into an SQL db.
    Query failed to convert 
     System.Int64 (incoming data format) to  System.Double ( SQL column data format)
    I solved it by changing SQL column format to int, but I think this casting should be done automatically by the query. I can also CAST the data I guess but sometimes using CAST on everything is kind of a pain.
    Another issue I faced was the failure messages. I checked the logs for last 12 hours. Sometimes the failure will point to the Writing Error (conversion of int to double) but sometimes the failure will simply be transient failure. So it was difficult to pinpoint
    the error exactly.
    Thanks anyways.

  • Authorizations for Profit center in a query for a TEST user

    Dear SAP BI Gurus
    I have a query which has to be tested by the different user based on the region & the profit center that they belong to in SAP BI 7.0
    for this i have to create a user id for the test user under he/she should be able to view only his/her profit center data.
    The following are the steps that  i  tried out.
    1.created a role .
    2. in the change role - authorization , i have added authorization object "ZPROFIT" to the RSR . & restricted the ZPROFIT for the given values of the profit centers.
    3. Added this role to the User ID.
    But still the user is able to view all the profit center in the query.
    This is bugging me up.....
    Can anyone help me out.
    Best Regards,
    Ramesh

    Dear chetan/ravi
    i did create all the authorization objects & filled in the values in them.
    Also a authorization variable has been created in the Query.
    But i dont know how this variable has to be linked to the Auth Objects in Rsecadmin.
    Can you explain me the steps involved in it.
    Best Regards,
    Ramesh

Maybe you are looking for

  • How can I retrieve my pages documents from another account in the iCloud

    I was using pages in my ipad. Then I bought a Mac Pro and signes with a new iCloud account. In order to sync it with my ipad I deleite the previous iCloud account from the divise and started it with the new account. I previously choose to keep all th

  • How to track the person who has stolen my macbook pro.

    I have lost my mac recently. but just now i have received email thru my another device showing that the thief has been tried to ask the question in apple support community. He asked about how to access new operating system because it can't be open by

  • What is Data source? How to create a datasource?

    Hi All,     anybody could you explain me What is Data source and how to create data source? How it is related to BW. Points will be rewarded for all the useful answers. Priya.

  • Identifying Multiple Rotes out of a User Service in LC ES

    Hi I'm not sure if this is a WorkSpace or WorkBench issue so please advise if in wrong forum. We have created a number of LC ES processes that require 2 'routes' out of the user service at a number of stages in the process. These routes are typically

  • Leopard 10.5.2 update problems

    I'm using a MacBook Pro with a Cinema 23" display. This is my startup procedure: After booting I close the lid to make it go to sleep, then I hit a key on the keyboard to wake it up, then I type my password, and the last thing I do is to open up the