Compare commits

...

2 Commits

Author SHA1 Message Date
Alpha Chen d60889b13c [2016][rust][23.1] No inlining for profiling?
8 years ago
Alpha Chen 3ff87286de profiling
8 years ago

@ -7,3 +7,6 @@ authors = ["Alpha Chen <alpha.chen@gmail.com>"]
error-chain = "0.7"
regex = "0.1"
rust-crypto = "0.2"
[profile.release]
debug = true

@ -10,10 +10,12 @@ pub struct Assembunny {
}
impl Assembunny {
#[inline(never)]
fn instruction(&self, i: usize) -> Option<Instruction> {
self.instructions.get(i).cloned()
}
#[inline(never)]
fn value<V: Into<Variable>>(&self, v: V) -> isize {
let v: Variable = v.into();
match v {
@ -22,6 +24,7 @@ impl Assembunny {
}
}
#[inline(never)]
fn toggle(&mut self, i: usize) {
let instruction = match self.instruction(i) {
Some(x) => x,
@ -42,6 +45,7 @@ impl Assembunny {
impl Iterator for Assembunny {
type Item = Registers;
#[inline(never)]
fn next(&mut self) -> Option<Registers> {
let pc = self.value(Register::PC) as usize;
let instruction = match self.instruction(pc) {

@ -1,10 +1,11 @@
#![feature(field_init_shorthand, inclusive_range_syntax)]
#![feature(alloc_system, field_init_shorthand, inclusive_range_syntax)]
#![recursion_limit = "1024"]
extern crate alloc_system;
extern crate crypto;
#[macro_use]
extern crate error_chain;
extern crate regex;
extern crate crypto;
mod assembunny;
pub mod errors;

@ -1,5 +1,6 @@
use std::io;
use std::io::Read;
use std::env;
use std::fs::File;
use std::io::prelude::*;
extern crate advent_of_code_2016;
use advent_of_code_2016::*;
@ -7,8 +8,10 @@ use advent_of_code_2016::errors::*;
fn main() {
run(|| {
let filename = env::args().nth(1).ok_or("")?;
let mut f = File::open(filename).chain_err(|| "")?;
let mut input = String::new();
io::stdin().read_to_string(&mut input).ok();
f.read_to_string(&mut input).chain_err(|| "")?;
let solution = day_23::solve(&input)?;
println!("{}", solution);

Loading…
Cancel
Save