In this paper, the distribution power loss of DC microgrids comprising both line loss and converter loss is modelled as a quadratic function of current allocation coefficients, which is a convex function with constraints. On basis of convex optimization theory, the optimal current allocation coefficients are on-line calculated by Lagrange multiplier method. Then, an adaptive virtual resistance droop control (AVRDC) is proposed to achieve the given current-sharing rate. In the proposed control, the current-sharing error generates additional adaptive virtual resistance. It is known that the sum of virtual resistance and line resistance should be in inverse proportion to current distribution coefficient. By sampling data of two control periods, the line resistance can be identified in real time. In this way, the real-time efficiency optimization control of DC microgrid can be realized, regardless of line resistance variations. The effectiveness of the proposed control strategy is validated by both simulation and experimental results.