forked from bazelbuild/bazel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds arguments --version_between --time_between --versions to the ben…
…chmark as version filters. -- PiperOrigin-RevId: 147141691 MOS_MIGRATED_REVID=147141691
- Loading branch information
1 parent
3e73d9b
commit b3589a0
Showing
14 changed files
with
384 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/tools/benchmark/java/com/google/devtools/build/benchmark/DateFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2017 The Bazel Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package com.google.devtools.build.benchmark; | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
|
||
/** | ||
* Contains start date and end date. | ||
*/ | ||
class DateFilter { | ||
|
||
static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); | ||
|
||
private final Date from; | ||
private final Date to; | ||
|
||
public DateFilter(Date from, Date to) { | ||
this.from = from; | ||
this.to = to; | ||
} | ||
|
||
public String getFromString() { | ||
return DATE_FORMAT.format(from); | ||
} | ||
|
||
public String getToString() { | ||
return DATE_FORMAT.format(to); | ||
} | ||
|
||
} |
67 changes: 67 additions & 0 deletions
67
src/tools/benchmark/java/com/google/devtools/build/benchmark/DateFilterConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright 2017 The Bazel Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package com.google.devtools.build.benchmark; | ||
|
||
import com.google.devtools.common.options.Converter; | ||
import com.google.devtools.common.options.OptionsParsingException; | ||
|
||
import java.text.ParseException; | ||
import java.util.Date; | ||
|
||
/** | ||
* A converter class that convert an input string to a {@link DateFilter} object. | ||
*/ | ||
public class DateFilterConverter implements Converter<DateFilter> { | ||
|
||
public DateFilterConverter() { | ||
super(); | ||
} | ||
|
||
@Override | ||
public DateFilter convert(String input) throws OptionsParsingException { | ||
if (input.isEmpty()) { | ||
return null; | ||
} | ||
|
||
String[] parts = input.split("\\.\\."); | ||
if (parts.length != 2) { | ||
throw new OptionsParsingException("Error parsing time_between option: no '..' found."); | ||
} | ||
if (parts[0].isEmpty()) { | ||
throw new OptionsParsingException( | ||
"Error parsing time_between option: start date not found"); | ||
} | ||
if (parts[1].isEmpty()) { | ||
throw new OptionsParsingException( | ||
"Error parsing time_between option: end date not found"); | ||
} | ||
|
||
// TODO(yueg): support more date formats | ||
try { | ||
Date from = DateFilter.DATE_FORMAT.parse(parts[0]); | ||
Date to = DateFilter.DATE_FORMAT.parse(parts[1]); | ||
return new DateFilter(from, to); | ||
} catch (ParseException e) { | ||
throw new OptionsParsingException( | ||
"Error parsing datetime, format should be: yyyy-MM-ddTHH:mm:ss"); | ||
} | ||
} | ||
|
||
@Override | ||
public String getTypeDescription() { | ||
return "A date filter in format: <start date(time)>..<end date(time)>"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.