1%% 2%% %CopyrightBegin% 3%% 4%% Copyright Ericsson AB 1999-2016. All Rights Reserved. 5%% 6%% Licensed under the Apache License, Version 2.0 (the "License"); 7%% you may not use this file except in compliance with the License. 8%% You may obtain a copy of the License at 9%% 10%% http://www.apache.org/licenses/LICENSE-2.0 11%% 12%% Unless required by applicable law or agreed to in writing, software 13%% distributed under the License is distributed on an "AS IS" BASIS, 14%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15%% See the License for the specific language governing permissions and 16%% limitations under the License. 17%% 18%% %CopyrightEnd% 19%% 20-module(beam_compiler_9). 21 22-export([compile/2, test/0, ?MODULE/0]). 23 24?MODULE() -> 25 ok. 26 27test() -> 28 Failures = failures(), 29 compile_files([hd(Failures)]). 30 31compile_files([File | Files]) -> 32 Pid = spawn(?MODULE, compile, [File, self()]), 33 Time = infinity, 34 receive 35 done -> 36 compile_files(Files) 37 after 38 Time -> 39 io:fwrite("Compilation not completed within ~w ms~n", [Time]), 40 exit(Pid, die), 41 compile_files(Files) 42 end; 43 44compile_files([]) -> 45 done. 46 47 48 49compile(File, Parent) -> 50 io:fwrite("Compiling: ~s~n", [File]), 51 statistics(runtime), 52 statistics(wall_clock), 53 statistics(reductions), 54 Result = c:c(File), 55 {_, Rslc} = statistics(runtime), 56 {_, Tslc} = statistics(wall_clock), 57 {_, Reds} = statistics(reductions), 58 io:fwrite("Result: ~w~n", [Result]), 59 io:fwrite("Reductions: ~w~n", [Reds]), 60 io:fwrite("Time: ~w~n", [Tslc]), 61 io:fwrite("Cpu time: ~w~n", [Rslc]), 62 io:nl(), 63 Parent ! done. 64 65 66 67failures() -> 68 [test]. 69