-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merging the fix that rids os malloc from sms object interactions
- Loading branch information
Showing
12 changed files
with
36 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
|
||
let f = (n) => | ||
if( n <= 1 ) | ||
n | ||
1 | ||
else | ||
f(n - 1) + f(n - 2); | ||
benchmark(:f(31)); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/local/bin/sms -qm 1800 | ||
# Use this to benchmark something | ||
# I came up with a faster fib that doesn't memoize | ||
|
||
{ | ||
let t1 =[]; | ||
let t2 =[]; | ||
let time_elapsed =0; | ||
let a =0; | ||
let benchmark = (e) => { | ||
putln("Benchmarking: " str+ toStr(e)); | ||
|
||
t1 = time(); | ||
putln(toStr(eval(e))); | ||
t2 = time(); | ||
|
||
putln("Total time:"); | ||
time_elapsed = 1000 * (t2[0] - t1[0]) + 0.001 * (t2[1] - t1[1]); | ||
putln(toStr(time_elapsed) str+ " milliseconds") | ||
}; | ||
|
||
let first5 = [1,1,2,3,5]; | ||
let f = (n) => { | ||
if(n<5) | ||
return first5[n]; | ||
let s2= f(n-2); | ||
let s3= f(n-3); | ||
let s4= f(n-4); | ||
|
||
return 2*s3+s4+s2 ; | ||
}; | ||
|
||
benchmark(:f(31)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
{ | ||
let in = ""; | ||
let ans = []; | ||
let env = {}; | ||
let env = _scratch; | ||
while(true){ | ||
put("> "); | ||
in = input(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.