With the advent of the era of the Internet of Things (IoT), massive amounts of data generated by computationally intensive mobile devices have brought a huge burden on network bandwidth resources. To tackle it, both device-to-device (D2D) and multi-access edge computing (MEC) technologies can further improve the computation capability of cellular networks. In this paper, we consider a single-cell wireless network based on MEC- D2D technology to maximize the utilization of computational resources of the edge server while minimizing the average task completion time. To that end, we minimize the offloading energy consumption of users when the task is indivisible. More specifically, we propose two computation offloading schemes by solving the computational resources allocation problem and the task offloading strategy of the edge server. We formulate the first optimization scheme of joint average time and resource allocation (JATRA) to minimize the average task completion time which is formulated by a 0-1 integer programming problem. By seeking the factor of computation resource allocation, the joint average time and energy consumption (JATEC) optimization scheme is carried out to minimize the energy consumption of task offloading. As the result evaluated by numerous simulations shown, the schemes we present significantly reduce the average task completion time and energy consumption compared with the baseline schemes.