Skip to content

Conversation

@wilderrodrigues
Copy link
Contributor

  • System.nanoTime() is the best way to measure elapsed time in Java.
  • It gives a resolution on the order of microseconds
  • The System.currentTimeMillis() is used when calculating absolut time.

Add unit tests to cover negative cases

  • Cover when the profile is not started/stopped

Test Environment

  • Management Server: CentOS 7.1
  • KVM

Tests successfully executed:

nosetests --with-marvin --marvin-config=/data/shared/marvin/mct-zone2-kvm2-ISOLATED.cfg -s -a tags=advanced,required_hardware=false
smoke/test_vm_life_cycle.py smoke/test_routers.py smoke/test_vpc_vpn.py smoke/test_reset_vm_on_reboot.py smoke/test_service_offerings.py
component/test_vpc_offerings.py smoke/test_privategw_acl.py smoke/test_network_acl.py

   - System.nanoTime() is the best way to measure elapsed time in Java.
   - It gives a resolution on the order of microseconds

The System.currentTimeMillis() is used when calculating absolut time.
   - Cover when the profile is not started/stopped
@asfbot
Copy link

asfbot commented Jun 23, 2015

cloudstack-pull-requests #629 SUCCESS
This pull request looks good

@asfgit asfgit closed this in f29bf1e Jun 23, 2015
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd use a new name for the var, like startTickInNanos (and of course stopTickInNanos)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The nanoTime() is given in Microseconds. So, the MS still fits in.

Cheers,
Wilder

@wilderrodrigues
Copy link
Contributor Author

Before we continue in a face-to-face chat, which would be better, just few point to take into account:

  • The Profiler class is used as a profiler, to just measure how long a code took to be executed; used along with sleep calls - like a stop watch; and, still, as a monitor - there are lock implementations based on it. It makes the Profile class a profile, a stop-watch and a monitor.
  • From a profiler perspective, do a Star, wait for 1 second, then a Stop and check how long it took to compute doesn't seem right to me.

The comments above are only related to the fact that the Profiler class is being exploited inside ACS.

Concerning the getDuration(). I agree that once it is taken into account to calculate milliseconds, it will be flaw.

In that case, it's too bad I trusted the existing test - which has a glitch in the assertion.

My suggestion is to refactor the getDuration(), renaming it into getDurationInMillis() and create a getDuration() which returns the nanotime - microseconds. The test has to be fixed as well.

kishankavala pushed a commit to kishankavala/cloudstack that referenced this pull request Jun 25, 2015
   - Cover when the profile is not started/stopped

Signed-off-by: wilderrodrigues <wrodrigues@schubergphilis.com>

This closes apache#509
shwstppr added a commit to shapeblue/cloudstack that referenced this pull request Jan 27, 2025
Addresses: shapeblue/cloudstack-apple#490

Adds framework layer change to allow retrieving and storing IOPS stats for storage pools. Custom `PrimaryStoreDriver` can implement method - `getStorageIopsStats` for returning IOPS stats. Existing method `getUsedIops` can also be overridden by such plugins when only used IOPS is returned.
For testing purpose, implementation has been added for simulator hypervisor plugin to return capacity and used IOPS for a pool.
For local storage pool, implementation has been added using iostat to return currently used IOPS.
StoragePoolResponse class has been updated to return IOPS values which allows showing IOPS values in UI for different storage pool related views and APIs.

Schema changes: [fr83-schema-changes.sql.txt](https://github.com/user-attachments/files/18006838/fr83-schema-changes.sql.txt)

Upstream PR: apache#10034

---------

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants