1 // Copyright (C) 2024 The Android Open Source Project
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
15 //! A utility wrapper around libprefetch that allows to record, replay and dump
16 //! prefetch data.
17
18 use log::error;
19
20 use prefetch_rs::args_from_env;
21 use prefetch_rs::dump;
22 use prefetch_rs::init_logging;
23 use prefetch_rs::record;
24 use prefetch_rs::replay;
25 use prefetch_rs::LogLevel;
26 use prefetch_rs::MainArgs;
27 use prefetch_rs::SubCommands;
28
main()29 fn main() {
30 init_logging(LogLevel::Debug);
31 let args: MainArgs = args_from_env();
32 let ret = match &args.nested {
33 SubCommands::Record(args) => record(args),
34 SubCommands::Replay(args) => replay(args),
35 SubCommands::Dump(args) => dump(args),
36 };
37
38 if let Err(err) = ret {
39 error!("{:?} command failed: {:?}", args, err);
40 }
41 }
42