chore: print runtime
This commit is contained in:
parent
b7e6f7b27f
commit
83b9294ac1
|
@ -1,4 +1,4 @@
|
||||||
(program
|
(program
|
||||||
1.0.0
|
1.0.0
|
||||||
[ (lam x (lam y [ (builtin addInteger) x y ])) (con integer 5) (con integer 7) ]
|
[ (force (builtin ifThenElse)) (con bool True) (con integer 1) (con string "yo") ]
|
||||||
)
|
)
|
||||||
|
|
|
@ -198,6 +198,7 @@ impl Machine {
|
||||||
Value::Delay(body) => self.compute(&body),
|
Value::Delay(body) => self.compute(&body),
|
||||||
Value::Builtin { fun, term, runtime } => {
|
Value::Builtin { fun, term, runtime } => {
|
||||||
let force_term = Term::Force(Box::new(term));
|
let force_term = Term::Force(Box::new(term));
|
||||||
|
println!("{:#?}", runtime);
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
rest => Err(Error::NonPolymorphicInstantiation(rest)),
|
rest => Err(Error::NonPolymorphicInstantiation(rest)),
|
||||||
|
@ -289,7 +290,7 @@ impl Machine {
|
||||||
let mut unspent_step_budget =
|
let mut unspent_step_budget =
|
||||||
self.costs.machine_costs.get(StepKind::try_from(i as u8)?);
|
self.costs.machine_costs.get(StepKind::try_from(i as u8)?);
|
||||||
|
|
||||||
unspent_step_budget.occurences(self.unbudgeted_steps[i] as i32);
|
unspent_step_budget.occurences(self.unbudgeted_steps[i] as i64);
|
||||||
|
|
||||||
self.spend_budget(unspent_step_budget)?;
|
self.spend_budget(unspent_step_budget)?;
|
||||||
|
|
||||||
|
@ -341,7 +342,7 @@ impl Value {
|
||||||
matches!(self, Value::Con(Constant::Integer(_)))
|
matches!(self, Value::Con(Constant::Integer(_)))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_ex_mem(&self) -> i32 {
|
pub fn to_ex_mem(&self) -> i64 {
|
||||||
match self {
|
match self {
|
||||||
Value::Con(_) => todo!(),
|
Value::Con(_) => todo!(),
|
||||||
Value::Delay(_) => 1,
|
Value::Delay(_) => 1,
|
||||||
|
|
|
@ -3,18 +3,28 @@ use crate::builtins::DefaultFunction;
|
||||||
use super::Value;
|
use super::Value;
|
||||||
|
|
||||||
/// Can be negative
|
/// Can be negative
|
||||||
#[derive(Debug, Clone, PartialEq, Copy, Default)]
|
#[derive(Debug, Clone, PartialEq, Copy)]
|
||||||
pub struct ExBudget {
|
pub struct ExBudget {
|
||||||
pub mem: i32,
|
pub mem: i64,
|
||||||
pub cpu: i32,
|
pub cpu: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ExBudget {
|
impl ExBudget {
|
||||||
pub fn occurences(&mut self, n: i32) {
|
pub fn occurences(&mut self, n: i64) {
|
||||||
self.mem *= n;
|
self.mem *= n;
|
||||||
self.cpu *= n;
|
self.cpu *= n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for ExBudget {
|
||||||
|
fn default() -> Self {
|
||||||
|
ExBudget {
|
||||||
|
mem: 14000000,
|
||||||
|
cpu: 10000000000,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct CostModel {
|
pub struct CostModel {
|
||||||
pub machine_costs: MachineCosts,
|
pub machine_costs: MachineCosts,
|
||||||
|
@ -595,12 +605,12 @@ pub struct CostingFun<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum OneArgument {
|
pub enum OneArgument {
|
||||||
ConstantCost(i32),
|
ConstantCost(i64),
|
||||||
LinearCost(LinearSize),
|
LinearCost(LinearSize),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OneArgument {
|
impl OneArgument {
|
||||||
pub fn cost(&self, x: i32) -> i32 {
|
pub fn cost(&self, x: i64) -> i64 {
|
||||||
match self {
|
match self {
|
||||||
OneArgument::ConstantCost(c) => *c,
|
OneArgument::ConstantCost(c) => *c,
|
||||||
OneArgument::LinearCost(m) => m.slope * x + m.intercept,
|
OneArgument::LinearCost(m) => m.slope * x + m.intercept,
|
||||||
|
@ -609,7 +619,7 @@ impl OneArgument {
|
||||||
}
|
}
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub enum TwoArguments {
|
pub enum TwoArguments {
|
||||||
ConstantCost(i32),
|
ConstantCost(i64),
|
||||||
LinearInX(LinearSize),
|
LinearInX(LinearSize),
|
||||||
LinearInY(LinearSize),
|
LinearInY(LinearSize),
|
||||||
AddedSizes(AddedSizes),
|
AddedSizes(AddedSizes),
|
||||||
|
@ -622,7 +632,7 @@ pub enum TwoArguments {
|
||||||
ConstBelowDiagonal(ConstantOrTwoArguments),
|
ConstBelowDiagonal(ConstantOrTwoArguments),
|
||||||
}
|
}
|
||||||
impl TwoArguments {
|
impl TwoArguments {
|
||||||
pub fn cost(&self, x: i32, y: i32) -> i32 {
|
pub fn cost(&self, x: i64, y: i64) -> i64 {
|
||||||
match self {
|
match self {
|
||||||
TwoArguments::ConstantCost(c) => *c,
|
TwoArguments::ConstantCost(c) => *c,
|
||||||
TwoArguments::LinearInX(l) => l.slope * x + l.intercept,
|
TwoArguments::LinearInX(l) => l.slope * x + l.intercept,
|
||||||
|
@ -660,7 +670,7 @@ impl TwoArguments {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum ThreeArguments {
|
pub enum ThreeArguments {
|
||||||
ConstantCost(i32),
|
ConstantCost(i64),
|
||||||
AddedSizes(AddedSizes),
|
AddedSizes(AddedSizes),
|
||||||
LinearInX(LinearSize),
|
LinearInX(LinearSize),
|
||||||
LinearInY(LinearSize),
|
LinearInY(LinearSize),
|
||||||
|
@ -668,7 +678,7 @@ pub enum ThreeArguments {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ThreeArguments {
|
impl ThreeArguments {
|
||||||
pub fn cost(&self, x: i32, y: i32, z: i32) -> i32 {
|
pub fn cost(&self, x: i64, y: i64, z: i64) -> i64 {
|
||||||
match self {
|
match self {
|
||||||
ThreeArguments::ConstantCost(c) => *c,
|
ThreeArguments::ConstantCost(c) => *c,
|
||||||
ThreeArguments::AddedSizes(s) => (x + y + z) * s.slope + s.intercept,
|
ThreeArguments::AddedSizes(s) => (x + y + z) * s.slope + s.intercept,
|
||||||
|
@ -680,11 +690,11 @@ impl ThreeArguments {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum SixArguments {
|
pub enum SixArguments {
|
||||||
ConstantCost(i32),
|
ConstantCost(i64),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SixArguments {
|
impl SixArguments {
|
||||||
pub fn cost(&self, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32) -> i32 {
|
pub fn cost(&self, _: i64, _: i64, _: i64, _: i64, _: i64, _: i64) -> i64 {
|
||||||
match self {
|
match self {
|
||||||
SixArguments::ConstantCost(c) => *c,
|
SixArguments::ConstantCost(c) => *c,
|
||||||
}
|
}
|
||||||
|
@ -693,51 +703,51 @@ impl SixArguments {
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct LinearSize {
|
pub struct LinearSize {
|
||||||
pub intercept: i32,
|
pub intercept: i64,
|
||||||
pub slope: i32,
|
pub slope: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct AddedSizes {
|
pub struct AddedSizes {
|
||||||
pub intercept: i32,
|
pub intercept: i64,
|
||||||
pub slope: i32,
|
pub slope: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct SubtractedSizes {
|
pub struct SubtractedSizes {
|
||||||
pub intercept: i32,
|
pub intercept: i64,
|
||||||
pub slope: i32,
|
pub slope: i64,
|
||||||
pub minimum: i32,
|
pub minimum: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct MultipliedSizes {
|
pub struct MultipliedSizes {
|
||||||
pub intercept: i32,
|
pub intercept: i64,
|
||||||
pub slope: i32,
|
pub slope: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct MinSize {
|
pub struct MinSize {
|
||||||
pub intercept: i32,
|
pub intercept: i64,
|
||||||
pub slope: i32,
|
pub slope: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct MaxSize {
|
pub struct MaxSize {
|
||||||
pub intercept: i32,
|
pub intercept: i64,
|
||||||
pub slope: i32,
|
pub slope: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct ConstantOrLinear {
|
pub struct ConstantOrLinear {
|
||||||
pub constant: i32,
|
pub constant: i64,
|
||||||
pub intercept: i32,
|
pub intercept: i64,
|
||||||
pub slope: i32,
|
pub slope: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct ConstantOrTwoArguments {
|
pub struct ConstantOrTwoArguments {
|
||||||
pub constant: i32,
|
pub constant: i64,
|
||||||
pub model: Box<TwoArguments>,
|
pub model: Box<TwoArguments>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue