1. A code generating method, applied to a scheduling system, wherein the scheduling system comprises a heterogeneous system, a compiler, and an executable code, wherein the executable code is applied to the heterogeneous system, wherein the heterogeneous system comprises an accelerated processor and a central processing unit (CPU), and wherein the method comprises: acquiring, by the compiler, resource information of the accelerated processor and resource information of the CPU in order to generate an operable platform list; identifying accelerable code from first user code according to the resource information of the accelerated processor, wherein the operable platform list comprises all accelerated processors and CPUs; randomly selecting a portion of the executable code as test code; executing the test code on each of the accelerated processors and CPUs to determine a running cost for each of the accelerated processors and CPUs, wherein the running costs correspond to times for running the test code, and wherein a higher running cost indicates a longer time for running the test code; embedding, by the compiler, a hook function and an exception handling function to the accelerable code to form second user code, wherein the hook function generates an exception before running the accelerable code, and wherein the exception handling function comprises condition control code that is configured to handle the exception and select one of the accelerated processors or the CPUs to execute the accelerable code based on the running cost for each of the accelerated processors and CPUs; and compiling, by the compiler, the second user code to obtain the executable code of the scheduling system, wherein the executable code comprises executable user code obtained by compiling the hook function and the exception handling function, wherein the executable code further comprises first accelerable branch code and second accelerable branch code that are obtained by compiling the accelerable code, wherein the first accelerable branch code is executed by an accelerated processor in the operable platform list, wherein the second accelerable branch code is executed by a CPU in the operable platform list, wherein a purpose of embedding the hook function and the exception handling function is to use the condition control code in the exception handling function to select target processors for the first accelerable branch code and the second accelerable branch code when the hook function is being executed in a process of executing the executable code, wherein before compiling, by the compiler, the second user code to obtain the executable code, the method further comprises selecting, by the compiler, from the accelerated processors, a preset quantity of accelerated processors whose running cost is less than a preset value in order to generate a preferential processor list, wherein the preferential processor list comprises the preset quantity of accelerated processors that are in the operable platform list and whose running cost is less than the preset value, and wherein the first accelerable branch code is executed by an accelerated processor in the preferential processor list.