Sensing in cognitive radio (CR) protects the primary user (PU) from bad interference. Therefore, it is assumed to be a requirement. However, sensing has two main challenges; first the CR is required to sense the PU under very low signal to noise ratios which will take longer sensing time, and second, some CR nodes may suffer from deep fading and shadowing effects. Cooperative spectrum sensing (CSS) is supposed to solve these challenges. However, CSS adds extra energy consumption due to CRs send the sensing result to the fusion center and receive the final decision from the fusion center. This is in addition to the sensing energy itself. Therefore, CSS may consume considerable energy out of the battery of the CR node. Therefore in this paper, we try to find jointly the sensing time required from each CR node and the number of CR nodes who should perform sensing such that the energy and energy efficiency (i.e., ratio of throughput to energy consumed) are optimized. Simulation results show that the joint optimization achieves better in terms of energy efficiency than other approaches that perform separate optimization.