Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,70 +0,0 @@
|
|||
-- licenselist.adb --
|
||||
-- run under GPS 4.3-5 (Sidux/Debian)
|
||||
-- process rosetta.org text_processing/3 example
|
||||
-- uses linked-list to hold times
|
||||
with Ada.Text_IO, Ada.Integer_Text_IO, Ada.Strings.Unbounded,
|
||||
Ada.Strings.Unbounded.Text_IO,
|
||||
Ada.Containers.Doubly_Linked_Lists;
|
||||
use Ada.Text_IO, Ada.Integer_Text_IO,
|
||||
Ada.Strings.Unbounded, Ada.Strings.Unbounded.Text_IO,
|
||||
Ada.Containers;
|
||||
|
||||
procedure licenselist is
|
||||
|
||||
type logrec is record -- define a record 'logrec' to place in a list
|
||||
logtext : String(1..19);
|
||||
end record;
|
||||
|
||||
package dblist is new Doubly_Linked_Lists(logrec);
|
||||
use dblist;
|
||||
-- declare dblist as a list of logrec's
|
||||
licenselog : list;
|
||||
logtime : logrec;
|
||||
-- to record the time of max OUT licenses
|
||||
|
||||
infile : File_Type; -- file handle
|
||||
str : Unbounded_String; -- input string buffer of unknown length
|
||||
outcnt, maxoutcnt : integer := 0;
|
||||
infilename : string := "license.log";
|
||||
|
||||
procedure trace_times is
|
||||
-- loop thru times list and print
|
||||
pntr : cursor := licenselog.first;
|
||||
-- pntr is of system type cursor reference to local list 'licenselog'
|
||||
begin
|
||||
new_line;
|
||||
while has_element(pntr) loop
|
||||
put(element(pntr).logtext); new_line;
|
||||
next(pntr);
|
||||
end loop;
|
||||
end trace_times;
|
||||
|
||||
begin -- main program --
|
||||
open ( infile,
|
||||
mode=> in_file,
|
||||
name=> infilename );
|
||||
|
||||
loop
|
||||
exit when End_of_file ( infile );
|
||||
str := get_line( infile );
|
||||
if index( str, "OUT" ) > 0 then -- test if OUT record
|
||||
outcnt := outcnt +1;
|
||||
else -- else assume IN record
|
||||
outcnt := outcnt -1;
|
||||
end if;
|
||||
if outcnt > maxoutcnt then
|
||||
maxoutcnt := outcnt;
|
||||
logtime.logtext := slice(str,15,33); -- date_time field
|
||||
licenselog.clear; -- reset list for new time(s)
|
||||
licenselog.append (logtime); -- put current time into list
|
||||
elsif outcnt = maxoutcnt then
|
||||
logtime.logtext := slice(str,15,33); -- date_time field
|
||||
licenselog.append (logtime); -- add current time into list
|
||||
end if; -- have to account for possibility of equal number of OUT's
|
||||
end loop;
|
||||
put("The max. number of licenses OUT is ");put(maxoutcnt,5); new_line;
|
||||
put(" at these times ");
|
||||
|
||||
trace_times;
|
||||
close ( infile );
|
||||
end licenselist;
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. max-licenses-in-use.
|
||||
|
||||
ENVIRONMENT DIVISION.
|
||||
INPUT-OUTPUT SECTION.
|
||||
FILE-CONTROL.
|
||||
SELECT license-file ASSIGN "mlijobs.txt"
|
||||
ORGANIZATION LINE SEQUENTIAL
|
||||
FILE STATUS file-status.
|
||||
|
||||
DATA DIVISION.
|
||||
FILE SECTION.
|
||||
FD license-file.
|
||||
01 license-record.
|
||||
03 FILLER PIC X(8).
|
||||
03 action PIC X(3).
|
||||
88 license-out VALUE "OUT".
|
||||
03 FILLER PIC X(3).
|
||||
03 license-timestamp PIC X(19).
|
||||
03 FILLER PIC X(13).
|
||||
|
||||
WORKING-STORAGE SECTION.
|
||||
01 file-status PIC XX.
|
||||
88 file-ok VALUE "00".
|
||||
|
||||
01 max-licenses-out PIC 9(6).
|
||||
01 num-max-times PIC 99.
|
||||
01 max-license-times-area.
|
||||
03 max-timestamps PIC X(19) OCCURS 1 TO 50 TIMES
|
||||
DEPENDING ON num-max-times.
|
||||
01 current-licenses-out PIC 9(6).
|
||||
|
||||
01 i PIC 99.
|
||||
|
||||
PROCEDURE DIVISION.
|
||||
DECLARATIVES.
|
||||
license-file-error SECTION.
|
||||
USE AFTER ERROR ON license-file.
|
||||
|
||||
DISPLAY "An unexpected error has occurred. Error "
|
||||
file-status ". The program will close."
|
||||
GOBACK
|
||||
.
|
||||
END DECLARATIVES.
|
||||
|
||||
main-line.
|
||||
OPEN INPUT license-file
|
||||
IF NOT file-ok
|
||||
DISPLAY "File could not be opened. Error " file-status
|
||||
"."
|
||||
GOBACK
|
||||
END-IF
|
||||
|
||||
PERFORM FOREVER
|
||||
READ license-file
|
||||
AT END
|
||||
EXIT PERFORM
|
||||
END-READ
|
||||
|
||||
IF license-out
|
||||
ADD 1 TO current-licenses-out
|
||||
|
||||
EVALUATE TRUE
|
||||
WHEN current-licenses-out > max-licenses-out
|
||||
MOVE 1 TO num-max-times
|
||||
MOVE current-licenses-out TO max-licenses-out
|
||||
MOVE license-timestamp
|
||||
TO max-timestamps (num-max-times)
|
||||
|
||||
WHEN current-licenses-out = max-licenses-out
|
||||
ADD 1 TO num-max-times
|
||||
MOVE license-timestamp
|
||||
TO max-timestamps (num-max-times)
|
||||
END-EVALUATE
|
||||
ELSE
|
||||
SUBTRACT 1 FROM current-licenses-out
|
||||
END-IF
|
||||
END-PERFORM
|
||||
|
||||
CLOSE license-file
|
||||
|
||||
DISPLAY "License count at log end: " current-licenses-out
|
||||
DISPLAY "Maximum simulataneous licenses: " max-licenses-out
|
||||
DISPLAY "Time(s):"
|
||||
PERFORM VARYING i FROM 1 BY 1 UNTIL num-max-times < i
|
||||
DISPLAY max-timestamps (i)
|
||||
END-PERFORM
|
||||
|
||||
GOBACK
|
||||
.
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
function split(sequence s, integer c)
|
||||
sequence out
|
||||
integer first, delim
|
||||
out = {}
|
||||
first = 1
|
||||
while first <= length(s) do
|
||||
delim = find_from(c, s, first)
|
||||
if delim = 0 then
|
||||
delim = length(s) + 1
|
||||
end if
|
||||
out = append(out, s[first..delim-1])
|
||||
first = delim + 1
|
||||
end while
|
||||
return out
|
||||
end function
|
||||
|
||||
include get.e
|
||||
function val(sequence s)
|
||||
sequence v
|
||||
v = value(s)
|
||||
return v[2] - v[1] * v[1]
|
||||
end function
|
||||
|
||||
constant fn = open("mlijobs.txt", "r")
|
||||
integer maxout
|
||||
sequence jobs, line, maxtime
|
||||
object x
|
||||
jobs = {}
|
||||
maxout = 0
|
||||
while 1 do
|
||||
x = gets(fn)
|
||||
if atom(x) then
|
||||
exit
|
||||
end if
|
||||
line = split(x, ' ')
|
||||
line[$] = val(line[$])
|
||||
if equal(line[2], "OUT") then
|
||||
jobs &= line[$]
|
||||
if length(jobs) > maxout then
|
||||
maxout = length(jobs)
|
||||
maxtime = {line[4]}
|
||||
elsif length(jobs) = maxout then
|
||||
maxtime = append(maxtime, line[4])
|
||||
end if
|
||||
else
|
||||
jobs[find(line[$],jobs)] = jobs[$]
|
||||
jobs = jobs[1..$-1]
|
||||
end if
|
||||
end while
|
||||
close(fn)
|
||||
|
||||
printf(1, "Maximum simultaneous license use is %d at the following times:\n", maxout)
|
||||
for i = 1 to length(maxtime) do
|
||||
printf(1, "%s\n", {maxtime[i]})
|
||||
end for
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
[int]$count = 0
|
||||
[int]$maxCount = 0
|
||||
[datetime[]]$times = @()
|
||||
|
||||
$jobs = Get-Content -Path ".\mlijobs.txt" | ForEach-Object {
|
||||
[string[]]$fields = $_.Split(" ",[StringSplitOptions]::RemoveEmptyEntries)
|
||||
[datetime]$datetime = Get-Date $fields[3].Replace("_"," ")
|
||||
[PSCustomObject]@{
|
||||
State = $fields[1]
|
||||
Date = $datetime
|
||||
Job = $fields[6]
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($job in $jobs)
|
||||
{
|
||||
switch ($job.State)
|
||||
{
|
||||
"IN"
|
||||
{
|
||||
$count--
|
||||
}
|
||||
"OUT"
|
||||
{
|
||||
$count++
|
||||
|
||||
if ($count -gt $maxCount)
|
||||
{
|
||||
$maxCount = $count
|
||||
$times = @()
|
||||
$times+= $job.Date
|
||||
}
|
||||
elseif ($count -eq $maxCount)
|
||||
{
|
||||
$times+= $job.Date
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[PSCustomObject]@{
|
||||
LicensesOut = $maxCount
|
||||
StartTime = $times[0]
|
||||
EndTime = $times[1]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue