In this study, the average throughput maximisation of a secondary user (SU) by optimising its spectrum sensing time is formulated, assuming that a priori knowledge of the presence and absence probabilities of the primary users (PUs) is available. The energy consumed to find a transmission opportunity is evaluated, and a discussion on the impacts of the number of PUs on SU throughput and consumed energy are presented. To avoid the challenges associated with the analytical method, as a second solution, a systematic adaptive neural network-based sensing time optimisation approach is also proposed. The proposed scheme is able to find the optimum value of the channel sensing time without any prior knowledge or assumption about the wireless environment. The structure, performance and cooperation of the artificial neural networks used in the proposed method are explained in detail, and a set of illustrative simulation results is presented to validate the analytical results as well as the performance of the proposed learning-based optimisation scheme.