1. A method for optimizing hardware monitoring on a computing device, comprising: receiving, on the computing device, a monitoring request to monitor a portion of code or data within a process executing on the computing device; generating from the monitoring request a first monitoring configuration parameter for a first hardware monitoring component in the computing device; identifying a non-optimal event pattern that occurs while the first hardware monitoring component monitors the portion of code or data according to the first monitoring configuration parameter; applying a transformation to the portion of code or data; and reconfiguring the first hardware monitoring component by modifying the first monitoring configuration parameter in response to the transformation of the portion of code or data.