blob: 5a3d6932d4913c1e09735a4e1d7f6a79804f9b34 [file] [log] [blame]
Googler813d3bd2024-01-24 08:16:08 -08001// Copyright 2024 The Bazel Authors. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package com.google.devtools.build.lib.metrics;
16
17import com.google.auto.value.AutoValue;
18import com.google.common.collect.ImmutableMap;
19import java.time.Instant;
20
21/** Contains a snapshot of the resource usage of multiple processes. */
22@AutoValue
23public abstract class ResourceSnapshot {
24 /** Overall memory consumption by all descendant processes including initial process. */
25 public abstract ImmutableMap<Long, Integer> getPidToMemoryInKb();
26
27 /** Time when this snapshot was collected. */
28 public abstract Instant getCollectionTime();
29
30 public static ResourceSnapshot create(
31 ImmutableMap<Long, Integer> pidToMemoryInKb, Instant collectionTime) {
32 return new AutoValue_ResourceSnapshot(pidToMemoryInKb, collectionTime);
33 }
34
Googlerc3c8f152024-02-08 04:03:05 -080035 public static ResourceSnapshot createEmpty(Instant collectionTime) {
36 return new AutoValue_ResourceSnapshot(ImmutableMap.of(), collectionTime);
Googler813d3bd2024-01-24 08:16:08 -080037 }
38}