// Copyright Kani Contributors // SPDX-License-Identifier: Apache-2.0 OR MIT //! This test checks the performance with different struct definitions //! The test is from https://github.com/model-checking/kani/issues/1958. //! With CBMC 5.72.0, all harnesses take ~1 second #[derive(PartialEq, Eq)] enum Expr { A, B(Box), C(Box, Box), D(Box, Box, Box), E(Box, Box, Box, Box), } #[derive(PartialEq, Eq)] enum Result { Ok(S), Err(T), } impl Result { fn unwrap(&self) -> &S { let x = match self { Result::Ok(x) => x, Result::Err(_) => panic!(), }; x } } enum Err { A(X), B(Y, Z), } type Err1 = Err; type Err2<'a> = Err; type Err3<'a> = Err; type Err4<'a> = Err; type Err5<'a> = Err<&'a str, String, String>; type Err6<'a> = Err<&'a str, &'a str, String>; type Err7<'a> = Err<&'a str, String, &'a str>; type Err8<'a> = Err<&'a str, &'a str, &'a str>; type Err9<'a> = Err; type Err10<'a> = Err, &'a str, String>; // Takes >10s #[cfg_attr(kani, kani::proof, kani::unwind(2))] fn slow_harness1() { let x: Result = Result::Ok(Expr::A); assert_eq!(x.unwrap(), &Expr::A); } // Takes >10s #[cfg_attr(kani, kani::proof, kani::unwind(2))] fn slow_harness2() { let x: Result = Result::Ok(Expr::A); assert_eq!(x.unwrap(), &Expr::A); } // Takes ~1s #[cfg_attr(kani, kani::proof, kani::unwind(2))] fn fast_harness() { let x: Result = Result::Ok(Expr::A); assert_eq!(x.unwrap(), &Expr::A); let x: Result = Result::Ok(Expr::A); assert_eq!(x.unwrap(), &Expr::A); let x: Result = Result::Ok(Expr::A); assert_eq!(x.unwrap(), &Expr::A); let x: Result = Result::Ok(Expr::A); assert_eq!(x.unwrap(), &Expr::A); let x: Result = Result::Ok(Expr::A); assert_eq!(x.unwrap(), &Expr::A); let x: Result = Result::Ok(Expr::A); assert_eq!(x.unwrap(), &Expr::A); let x: Result = Result::Ok(Expr::A); assert_eq!(x.unwrap(), &Expr::A); let x: Result = Result::Ok(Expr::A); assert_eq!(x.unwrap(), &Expr::A); let x: Result = Result::Ok(Expr::A); assert_eq!(x.unwrap(), &Expr::A); let x: Result = Result::Ok(Expr::A); assert_eq!(x.unwrap(), &Expr::A); } fn main() {}