Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/library_go_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ jobs:
# the sys.path workaround for generated Dafny doesn't work on Windows.
# Note: only tests use the sys.path workaround, not source code.
# Windows source code is tested downstream (ex. ESDK-Python CI).
# windows-latest,
# TODO: clarify the comment above given:
# Go tests should be performed on a
# windows machine because packages in StandardLibrary (Time_) uses
# the syscall package, which does not contain the same functions/types
# across operating systems.
windows-latest,
ubuntu-22.04,
macos-13,
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package _Time

import (
"syscall"
"time"

"github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Wrappers"
Expand Down Expand Up @@ -35,13 +34,4 @@ func CurrentRelativeTimeMilli() int64 {

func (CompanionStruct_Default___) GetProcessCpuTimeMillis() int64 {
return GetProcessCpuTimeMillis()
}

func GetProcessCpuTimeMillis() int64 {
var usage syscall.Rusage
err := syscall.Getrusage(syscall.RUSAGE_SELF, &usage)
if err != nil {
return 0
}
return (usage.Utime.Nano() + usage.Stime.Nano()) / 1000000
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//go:build !windows
// +build !windows

package _Time

import (
"syscall"
)



func GetProcessCpuTimeMillis() int64 {
var usage syscall.Rusage
err := syscall.Getrusage(syscall.RUSAGE_SELF, &usage)
if err != nil {
return 0
}
return (usage.Utime.Nano() + usage.Stime.Nano()) / 1000000
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//go:build windows
// +build windows

package _Time

import (
"golang.org/x/sys/windows"
)


func GetProcessCpuTimeMillis() int64 {
windows.GetCurrentProcessId()
var proc_handle windows.Handle
var err error
if proc_handle, err = windows.OpenProcess(windows.PROCESS_QUERY_INFORMATION|windows.PROCESS_VM_READ, false, uint32(windows.GetCurrentProcessId())); err != nil {
return 0
}
var creation_time, exit_time, kernel_time, user_time *windows.Filetime
if err = windows.GetProcessTimes(proc_handle, creation_time, exit_time, kernel_time, user_time); err != nil {
return 0
}
return (int64(kernel_time.Nanoseconds()) + int64(user_time.Nanoseconds())) / 1000000
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
module github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library

go 1.23.0
go 1.24.0

require github.com/dafny-lang/DafnyRuntimeGo/v4 v4.9.2

require github.com/google/uuid v1.6.0

require golang.org/x/sys v0.36.0 // indirect
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ github.com/dafny-lang/DafnyRuntimeGo/v4 v4.9.2 h1:g/xAj4F7Zt9wXJ6QjfbfocVi/ZYlAF
github.com/dafny-lang/DafnyRuntimeGo/v4 v4.9.2/go.mod h1:l2Tm4N2DKuq3ljONC2vOATeM9PUpXbIc8SgXdwwqEto=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=