Commit 00a52420 authored by Mol Thomas Folkert's avatar Mol Thomas Folkert
Browse files

removed generated code from repo

parent 5b258718
const std = @import("std");
const ctime = @cImport({
@cInclude("time.h");
});
fn comptime_loop() i32 {
const _lo: i32 = 0;
const _hi: i32 = 5;
const _arr = [_]i32{1, 2, 3, 4, 5};
var _acc: i32 = 0;
var i: usize = @intCast(usize, _lo);
while (i < _hi) : (i += 1) {
_acc += _arr[i];
}
return _acc;
}
fn volatile_loop() i32 {
const _lo: i32 = 0;
var _hi: i32 = 5;
var _hi_p: *volatile i32 = &_hi;
var _arr = [_]i32{1, 2, 3, 4, 5};
var _arr_p: []volatile i32 = &_arr;
var _acc: i32 = 0;
var i: usize = @intCast(usize, _lo);
while (i < _hi_p.*) : (i += 1) {
_acc += _arr_p[i];
}
return _acc;
}
fn _internal_passed_p(_lo: i32, _hi: *i32, _arr: [*]const i32) i32 {
var _acc: i32 = 0;
var i: usize = @intCast(usize, _lo);
while (i < _hi.*) : (i += 1) {
_acc += _arr[i];
}
return _acc;
}
fn passed_loop() i32 {
const _lo: i32 = 0;
var _hi: i32 = 5;
var _arr: [*]const i32 = &[5]i32{1, 2, 3, 4, 5};
return _internal_passed_p(_lo, &_hi, _arr);
}
fn _hi_fn() i32 {
return 5;
}
var _fn_arr: [*]const i32 = &[5]i32{1, 2, 3, 4, 5};
fn _arr_fn() [*]const i32 {
return _fn_arr;
}
fn _internal_passed_fn(_hi_fn_p: fn () i32, _arr_fn_p: fn () [*]const i32) i32 {
const lo: i32 = 0;
var _acc: i32 = 0;
var i: usize = @intCast(usize, lo);
while (i < _hi_fn_p()) : (i += 1) {
_acc += _arr_fn_p()[i];
}
return _acc;
}
fn function_loop() i32 {
return _internal_passed_fn(_hi_fn, _arr_fn);
}
pub fn main() !void {
const comptime_loop_stdout = std.io.getStdOut().writer();
var comptime_loop_start: ctime.timespec = .{.tv_sec = 0, .tv_nsec = 0};
var comptime_loop_end: ctime.timespec = .{.tv_sec = 0, .tv_nsec = 0};
_ = ctime.clock_gettime(ctime.CLOCK_MONOTONIC_RAW, &comptime_loop_start);
_ = comptime_loop();
_ = ctime.clock_gettime(ctime.CLOCK_MONOTONIC_RAW, &comptime_loop_end);
var comptime_loop_duration: c_long = comptime_loop_end.tv_nsec - comptime_loop_start.tv_nsec;
try comptime_loop_stdout.print("comptime_loop done. {d} nanoseconds\n", .{comptime_loop_duration});
const volatile_loop_stdout = std.io.getStdOut().writer();
var volatile_loop_start: ctime.timespec = .{.tv_sec = 0, .tv_nsec = 0};
var volatile_loop_end: ctime.timespec = .{.tv_sec = 0, .tv_nsec = 0};
_ = ctime.clock_gettime(ctime.CLOCK_MONOTONIC_RAW, &volatile_loop_start);
_ = volatile_loop();
_ = ctime.clock_gettime(ctime.CLOCK_MONOTONIC_RAW, &volatile_loop_end);
var volatile_loop_duration: c_long = volatile_loop_end.tv_nsec - volatile_loop_start.tv_nsec;
try volatile_loop_stdout.print("volatile_loop done. {d} nanoseconds\n", .{volatile_loop_duration});
const passed_loop_stdout = std.io.getStdOut().writer();
var passed_loop_start: ctime.timespec = .{.tv_sec = 0, .tv_nsec = 0};
var passed_loop_end: ctime.timespec = .{.tv_sec = 0, .tv_nsec = 0};
_ = ctime.clock_gettime(ctime.CLOCK_MONOTONIC_RAW, &passed_loop_start);
_ = passed_loop();
_ = ctime.clock_gettime(ctime.CLOCK_MONOTONIC_RAW, &passed_loop_end);
var passed_loop_duration: c_long = passed_loop_end.tv_nsec - passed_loop_start.tv_nsec;
try passed_loop_stdout.print("passed_loop done. {d} nanoseconds\n", .{passed_loop_duration});
const function_loop_stdout = std.io.getStdOut().writer();
var function_loop_start: ctime.timespec = .{.tv_sec = 0, .tv_nsec = 0};
var function_loop_end: ctime.timespec = .{.tv_sec = 0, .tv_nsec = 0};
_ = ctime.clock_gettime(ctime.CLOCK_MONOTONIC_RAW, &function_loop_start);
_ = function_loop();
_ = ctime.clock_gettime(ctime.CLOCK_MONOTONIC_RAW, &function_loop_end);
var function_loop_duration: c_long = function_loop_end.tv_nsec - function_loop_start.tv_nsec;
try function_loop_stdout.print("function_loop done. {d} nanoseconds\n", .{function_loop_duration});
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment