Anonymous user
Text processing/Max licenses in use: Difference between revisions
Text processing/Max licenses in use (view source)
Revision as of 21:07, 17 September 2020
, 3 years agoAdd source for Rust
Thundergnat (talk | contribs) (Rename Perl 6 -> Raku, alphabetize, minor clean-up) |
(Add source for Rust) |
||
Line 42:
-- to record the time of max OUT licenses
infile
str
outcnt, maxoutcnt : integer := 0;
infilename : string := "license.log";
Line 74:
if outcnt > maxoutcnt then
maxoutcnt := outcnt;
licenselog.clear; -- reset list for new time(s)
licenselog.append (logtime); -- put current time into list
Line 247:
On a 2.53MHz machine, these timings were obtained using GNU Awk 4.0.2:
user
sys
=={{header|BBC BASIC}}==
Line 354:
if ( l_out == maxout ) {
if ( maxcount < MAX_MAXOUT ) {
} else {
}
}
Line 383:
int main()
{
}
}
}▼
}</lang>output<lang>2008/10/03_08:39:34 99
2008/10/03_08:40:40 99</lang>
Line 727:
<lang Eiffel>
class
create
feature
do
end
end
end
feature {NONE}
do
end
Line 793:
out_dates_from_file( Name ) ->
task() ->
Line 806:
out_dates( <<>>, Acc ) -> Acc;
out_dates( Line, {N, Date, Dict} ) ->
out_dates_dict( N, New_n, Date, Dict ) when N > New_n -> dict:append( N, Date, Dict );
Line 1,057:
import (
)
const (
)
func main() {
}
}
}
}
}
}
}
}
}
}</lang>
{{out}}
Line 1,341:
2008/10/03_08:40:40
real
user
sys
=={{header|Julia}}==
Line 1,468:
<pre>Maximum licenses in use: 99
Occurrences:
=={{header|M2000 Interpreter}}==
Line 1,543:
local maxOut = -1
local maxTimes = #()
while not EOF logFile do
(
Line 1,649:
for Job in {ReadLines Filename} do
case {List.take Job 11} of "License OUT" then
[] "License IN " then
end
end
Line 1,700:
=={{header|PARI/GP}}==
<lang parigp>license()={
,
)
,
)
};</lang>
<pre>["2008/10/03_08:39:34", "2008/10/03_08:40:40"]
Line 1,805:
$buffer = fgets($handle);
$op = trim(substr($buffer,8,3));
}
}
}
fclose ($handle);
Line 1,825:
echo $maxcount . '<br>';
for($i=0;$i<count($times);$i++){
}</lang>
<pre>
Line 2,327:
wend
print maxCount;" ";theDate$</lang>
=={{header|Rust}}==
<lang Rust>type Timestamp = String;
fn compute_usage<R, S, E>(lines: R) -> Result<(u32, Vec<Timestamp>), E>
where
S: AsRef<str>,
R: Iterator<Item = Result<S, E>>,
{
let mut timestamps = Vec::new();
let mut current = 0;
let mut maximum = 0;
for line in lines {
let line = line?;
let line = line.as_ref();
if line.starts_with("License IN") {
current -= 1;
} else if line.starts_with("License OUT") {
current += 1;
if maximum <= current {
let date = line.split_whitespace().nth(3).unwrap().to_string();
if maximum < current {
maximum = current;
timestamps.clear();
}
timestamps.push(date);
}
}
}
Ok((maximum, timestamps))
fn main() -> std::io::Result<()> {
use std::io::{BufRead, BufReader};
let file = std::fs::OpenOptions::new().read(true).open("mlijobs.txt")?;
let (max, timestamps) = compute_usage(BufReader::new(file).lines())?;
println!("Maximum licenses out: {}", max);
println!("At time(s): {:?}", timestamps);
Ok(())
}</lang>
=={{header|Scala}}==
|